问:
Use Selenium to click all youtube comment 'reply' buttons and get the username and content of the replies and comments
My goal is to scrape all the youtube comments and replies along with the username from a youtube comment section.

What I have done so far only gets the comments and not the user inside replies. It is relatively similar with this question but the Youtube interface has changed.

Below is a snippet of my code where it would input into Sqlite the authors and the comments or replies.

```<code>REPLIES_word = None

    replies = mc.find_element(By.XPATH, '..//*[@id="replies"]') # get the replies section of the above comment

    REPLIES_word = replies.text.split(" ")[1]
    if (REPLIES_word == "replies"): # check if there are any replies
        reply = replies.find_element(By.CSS_SELECTOR, 'a')
        driver.execute_script("arguments[0].scrollIntoView();", reply) # bring view replies into view
        driver.execute_script('window.scrollTo(0,(window.pageYOffset-150))') # cater for the youtube header
        try:
            reply.click() # if so open the replies
        except:
            pass
        time.sleep(sleep_timer) # wait for load (better strategy should be used here

        try:
            more_replies = replies.find_element(By.XPATH, '//*[@id="button"]/ytd-button-renderer')
            if more_replies.text.startswith('Show'):
                more_reply = more_replies.find_element(By.CSS_SELECTOR, 'a');
                driver.execute_script("arguments[0].scrollIntoView();", more_reply) # bring view replies into view
                driver.execute_script('window.scrollTo(0,(window.pageYOffset-150))') # cater for the youtube header
                more_reply.click() # if so open the replies
                time.sleep(sleep_timer) # wait for load (better strategy should be used here
        except:
            pass

        print ("Reply: ")

        reply_counter = 0

        for reply in replies.find_elements(By.ID, 'author-text'):
            reply_name = reply.text
            reply_counter = reply_counter + 1
            print(str(reply_counter) + " : " + reply_name)
            insert_reply_author( cursor, comment_counter, reply_counter, reply_name)

        print()

        reply_counter = 0

        for reply in replies.find_elements(By.ID, 'content-text'):
            reply_content = reply.text
            reply_counter = reply_counter + 1
            print(str(reply_counter) + " : " + reply_content)
            insert_reply_comment( connection, cursor, comment_counter, reply_counter, reply_content )

        print("----------")
</code>```

I'm currently having trouble with the line:

reply = replies.find_element(By.CSS_SELECTOR, 'a')

since Youtube interface has changed and I don't know how Selenium would be able to click the nested "Replies" section.

Any help would be appreciated.

I'm getting the following error:

```<code>Traceback (most recent call last):
File "/youtube_comments_replies_scraper2.py", line 156, in \<module\>
get_usernames_comments_replies( connection, cursor, driver )
File "/youtube_comments_replies_scraper2.py", line 70, in get_usernames_comments_replies
reply = replies.find_element(By.NAME, 'replies')
File "/usr/lib/python3.10/site-packages/selenium/webdriver/remote/webelement.py", line 433, in find_element
return self.\_execute(Command.FIND_CHILD_ELEMENT, {"using": by, "value": value})\["value"\]
File "/usr/lib/python3.10/site-packages/selenium/webdriver/remote/webelement.py", line 410, in \_execute
return self.\_parent.execute(command, params)
File "/usr/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 444, in execute
self.error_handler.check_response(response)
File "/usr/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 249, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"\[name="replies"\]"}
</code>```

Body:
My goal is to scrape all the youtube comments and replies along with the username from a youtube comment section.

What I have done so far only gets the comments and not the user inside replies. It is relatively similar with this question but the Youtube interface has changed.

Below is a snippet of my code where it would input into Sqlite the authors and the comments or replies.

REPLIES_word = None

    replies = mc.find_element(By.XPATH, '..//*[@id="replies"]') # get the replies section of the above comment

    REPLIES_word = replies.text.split(" ")[1]
    if (REPLIES_word == "replies"): # check if there are any replies
        reply = replies.find_element(By.CSS_SELECTOR, 'a')
        driver.execute_script("arguments[0].scrollIntoView();", reply) # bring view replies into view
        driver.execute_script('window.scrollTo(0,(window.pageYOffset-150))') # cater for the youtube header
        try:
            reply.click() # if so open the replies
        except:
            pass
        time.sleep(sleep_timer) # wait for load (better strategy should be used here

        try:
            more_replies = replies.find_element(By.XPATH, '//*[@id="button"]/ytd-button-renderer')
            if more_replies.text.startswith('Show'):
                more_reply = more_replies.find_element(By.CSS_SELECTOR, 'a');
                driver.execute_script("arguments[0].scrollIntoView();", more_reply) # bring view replies into view
                driver.execute_script('window.scrollTo(0,(window.pageYOffset-150))') # cater for the youtube header
                more_reply.click() # if so open the replies
                time.sleep(sleep_timer) # wait for load (better strategy should be used here
        except:
            pass

        print ("Reply: ")

        reply_counter = 0

        for reply in replies.find_elements(By.ID, 'author-text'):
            reply_name = reply.text
            reply_counter = reply_counter + 1
            print(str(reply_counter) + " : " + reply_name)
            insert_reply_author( cursor, comment_counter, reply_counter, reply_name)

        print()

        reply_counter = 0

        for reply in replies.find_elements(By.ID, 'content-text'):
            reply_content = reply.text
            reply_counter = reply_counter + 1
            print(str(reply_counter) + " : " + reply_content)
            insert_reply_comment( connection, cursor, comment_counter, reply_counter, reply_content )

        print("----------")

I'm currently having trouble with the line:

reply = replies.find_element(By.CSS_SELECTOR, 'a')

since Youtube interface has changed and I don't know how Selenium would be able to click the nested "Replies" section.

Any help would be appreciated.

I'm getting the following error:

Traceback (most recent call last):
File "/youtube_comments_replies_scraper2.py", line 156, in \<module\>
get_usernames_comments_replies( connection, cursor, driver )
File "/youtube_comments_replies_scraper2.py", line 70, in get_usernames_comments_replies
reply = replies.find_element(By.NAME, 'replies')
File "/usr/lib/python3.10/site-packages/selenium/webdriver/remote/webelement.py", line 433, in find_element
return self.\_execute(Command.FIND_CHILD_ELEMENT, {"using": by, "value": value})\["value"\]
File "/usr/lib/python3.10/site-packages/selenium/webdriver/remote/webelement.py", line 410, in \_execute
return self.\_parent.execute(command, params)
File "/usr/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 444, in execute
self.error_handler.check_response(response)
File "/usr/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 249, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"\[name="replies"\]"}


来源: stackexchange

问:
Ignoring header X-Firebase-Locale because its value was null. exception
I wanted to enable registration for Firebase on Flutter
I enabled Email/Password in Sign-in providers,
WI-FI is working good
but anyway the console returns an error however i connected Firebase plugins.
Maybe i did something wrong

Ignoring header X-Firebase-Locale because its value was null.

and

[firebase_auth/network-request-failed] A network error (such as
timeout, interrupted connection or unreachable host) has occurred.

```<code>import 'package:flutter/material.dart';
import 'package:hazmat/pages/chatpage.dart';
import 'package:hazmat/pages/loginpage.dart';
import 'package:firebase_auth/firebase_auth.dart';

class RegisterPage extends StatefulWidget {
  static String routename = 'register_page';

  @override
  _RegisterPageState createState() => _RegisterPageState();
}

class _RegisterPageState extends State<RegisterPage> {
  final _auth = FirebaseAuth.instance;
  String email = '';
  String password = '';

  bool _hidepass = true;

  final _formkey = GlobalKey<FormState>();

  final _emailcontroller = TextEditingController();
  final _passcontroller = TextEditingController();
  final _confcontroller = TextEditingController();

  final _mailfocus = FocusNode();
  final _passfocus = FocusNode();
  final _conffocus = FocusNode();

  void dispose() {
    _emailcontroller.dispose();
    _passcontroller.dispose();
    _confcontroller.dispose();

    _mailfocus.dispose();
    _passfocus.dispose();
    _conffocus.dispose();
  }

  void _changeFocus(BuildContext context, currentF, nextF) {
    currentF.unfocus();
    FocusScope.of(context).requestFocus(nextF);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Center(
        child: Form(
          key: _formkey,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Welcome to Anonymous family', style: TextStyle(fontSize: 15, fontFamily: 'MultiR'),),
              Padding(
                padding: const EdgeInsets.all(18.0),
                child: Text('Sign Up', style: TextStyle(fontSize: 50, fontFamily: 'MultiR'),),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: TextFormField(
                  focusNode: _mailfocus,
                  onChanged: (value) {
                    email = value;
                  },
                  onFieldSubmitted: (_) {
                    _changeFocus(context, _mailfocus, _passfocus);
                  },
                  controller: _emailcontroller,
                  decoration: InputDecoration(
                    labelText: 'Email',
                    labelStyle: TextStyle(color: Colors.black),
                    prefixIcon: Icon(Icons.mail, color: Colors.black,),
                    suffixIcon: GestureDetector(
                      onTap: () {
                        _emailcontroller.clear();
                      },
                      child: Icon(
                        Icons.delete,
                      ),
                    ),
                    enabledBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(10.0)),
                        borderSide: BorderSide(color: Colors.black, width: 1.0)),
                    focusedBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(20.0)),
                        borderSide: BorderSide(color: Colors.red, width: 1.0)),
                  ),
                  validator: _validateemail,
                  keyboardType: TextInputType.emailAddress,
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: TextFormField(
                  onChanged: (value) {
                    password = value;
                  },
                  onFieldSubmitted: (_) {
                    _changeFocus(context, _passfocus, _conffocus);
                  },
                  focusNode: _passfocus,
                  controller: _passcontroller,
                  obscureText: _hidepass,
                  decoration: InputDecoration(
                    labelText: 'Password',
                    labelStyle: TextStyle(color: Colors.black),
                    prefixIcon: Icon(Icons.password_outlined, color: Colors.black,),
                    suffixIcon: IconButton(
                      icon: Icon(
                        _hidepass ? Icons.visibility : Icons.visibility_off,
                      ),
                      onPressed: () {
                        setState(() {
                          _hidepass = !_hidepass;
                        });
                      },
                    ),
                    enabledBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(10.0)),
                        borderSide: BorderSide(color: Colors.black, width: 1.0)),
                    focusedBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(20.0)),
                        borderSide: BorderSide(color: Colors.red, width: 1.0)),
                  ),
                  maxLength: 8,
                  validator: _validatePassword,
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: TextFormField(
                  focusNode: _conffocus,
                  controller: _confcontroller,
                  obscureText: _hidepass,
                  decoration: InputDecoration(
                    labelText: 'Confirm Password',
                    prefixIcon: Icon(Icons.password_outlined),
                    suffixIcon: IconButton(
                      icon: Icon(
                        _hidepass ? Icons.visibility : Icons.visibility_off,
                      ),
                      onPressed: () {
                        setState(() {
                          _hidepass = !_hidepass;
                        });
                      },
                    ),
                    enabledBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(10.0)),
                        borderSide: BorderSide(color: Colors.black, width: 1.0)),
                    focusedBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(20.0)),
                        borderSide: BorderSide(color: Colors.red, width: 1.0)),
                  ),
                  maxLength: 8,
                  validator: _validatePassword,
                ),
              ),
              ElevatedButton(
                onPressed: () async {
                  try {
                    print(email);
                    print(password);
                    _submitform();
                    final newUser = await _auth.createUserWithEmailAndPassword(
                        email: email, password: password);
                    if (newUser != null) {
                      Navigator.pushNamed(context, ChatPage.routename);
                    }
                  }
                  catch (ex) {
                    print(ex);
                    print('WTF');
                  }
                },
                child: Text('Sign Up'),
                style: ElevatedButton.styleFrom(
                    padding: EdgeInsets.symmetric(horizontal: 100, vertical: 20),
                    backgroundColor: Colors.black
                ),
              ),
              TextButton(onPressed: () {
                Navigator.pushNamed(context, LoginPage.routename);
              }, child: Text('Already registered?'))
            ],
          ),
        ),
      ),
    );
  }

  void _submitform() {
    if (_formkey.currentState!.validate()) {
      // returns true if there's not any mistakes
      _formkey.currentState!.save();
    } else {
      print('Form is invalid');
    }
  }

  String? _validateemail(String? value) {
    if (value == null) {
      return "got null";
    } else if (value.isEmpty) {
      return 'This field is required';
    } else if (!_emailcontroller.text.contains('@')) {
      return 'invalid email address';
    } else {
      return null;
    }
  }

  String? _validatePassword(String? value) {
    if (_passcontroller.text.isEmpty) {
      return 'This field is required';
    }
    else if (_passcontroller.text.length < 8) {
      return 'minimum 8 characters required';
    } else {
      return null;
    }
  }
}
</code>```

app\build.gradle

```<code>dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:31.1.1')
    implementation 'com.google.firebase:firebase-analytics'
}

apply plugin: "com.google.gms.google-services"
</code>```

android\build.gradle

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

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.13'
    }
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I wanted to enable registration for Firebase on Flutter
I enabled Email/Password in Sign-in providers,
WI-FI is working good
but anyway the console returns an error however i connected Firebase plugins.
Maybe i did something wrong

Ignoring header X-Firebase-Locale because its value was null.

and

[firebase_auth/network-request-failed] A network error (such as
timeout, interrupted connection or unreachable host) has occurred.

import 'package:flutter/material.dart';
import 'package:hazmat/pages/chatpage.dart';
import 'package:hazmat/pages/loginpage.dart';
import 'package:firebase_auth/firebase_auth.dart';

class RegisterPage extends StatefulWidget {
  static String routename = 'register_page';

  @override
  _RegisterPageState createState() => _RegisterPageState();
}

class _RegisterPageState extends State<RegisterPage> {
  final _auth = FirebaseAuth.instance;
  String email = '';
  String password = '';

  bool _hidepass = true;

  final _formkey = GlobalKey<FormState>();

  final _emailcontroller = TextEditingController();
  final _passcontroller = TextEditingController();
  final _confcontroller = TextEditingController();

  final _mailfocus = FocusNode();
  final _passfocus = FocusNode();
  final _conffocus = FocusNode();

  void dispose() {
    _emailcontroller.dispose();
    _passcontroller.dispose();
    _confcontroller.dispose();

    _mailfocus.dispose();
    _passfocus.dispose();
    _conffocus.dispose();
  }

  void _changeFocus(BuildContext context, currentF, nextF) {
    currentF.unfocus();
    FocusScope.of(context).requestFocus(nextF);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: Center(
        child: Form(
          key: _formkey,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Welcome to Anonymous family', style: TextStyle(fontSize: 15, fontFamily: 'MultiR'),),
              Padding(
                padding: const EdgeInsets.all(18.0),
                child: Text('Sign Up', style: TextStyle(fontSize: 50, fontFamily: 'MultiR'),),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: TextFormField(
                  focusNode: _mailfocus,
                  onChanged: (value) {
                    email = value;
                  },
                  onFieldSubmitted: (_) {
                    _changeFocus(context, _mailfocus, _passfocus);
                  },
                  controller: _emailcontroller,
                  decoration: InputDecoration(
                    labelText: 'Email',
                    labelStyle: TextStyle(color: Colors.black),
                    prefixIcon: Icon(Icons.mail, color: Colors.black,),
                    suffixIcon: GestureDetector(
                      onTap: () {
                        _emailcontroller.clear();
                      },
                      child: Icon(
                        Icons.delete,
                      ),
                    ),
                    enabledBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(10.0)),
                        borderSide: BorderSide(color: Colors.black, width: 1.0)),
                    focusedBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(20.0)),
                        borderSide: BorderSide(color: Colors.red, width: 1.0)),
                  ),
                  validator: _validateemail,
                  keyboardType: TextInputType.emailAddress,
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: TextFormField(
                  onChanged: (value) {
                    password = value;
                  },
                  onFieldSubmitted: (_) {
                    _changeFocus(context, _passfocus, _conffocus);
                  },
                  focusNode: _passfocus,
                  controller: _passcontroller,
                  obscureText: _hidepass,
                  decoration: InputDecoration(
                    labelText: 'Password',
                    labelStyle: TextStyle(color: Colors.black),
                    prefixIcon: Icon(Icons.password_outlined, color: Colors.black,),
                    suffixIcon: IconButton(
                      icon: Icon(
                        _hidepass ? Icons.visibility : Icons.visibility_off,
                      ),
                      onPressed: () {
                        setState(() {
                          _hidepass = !_hidepass;
                        });
                      },
                    ),
                    enabledBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(10.0)),
                        borderSide: BorderSide(color: Colors.black, width: 1.0)),
                    focusedBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(20.0)),
                        borderSide: BorderSide(color: Colors.red, width: 1.0)),
                  ),
                  maxLength: 8,
                  validator: _validatePassword,
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: TextFormField(
                  focusNode: _conffocus,
                  controller: _confcontroller,
                  obscureText: _hidepass,
                  decoration: InputDecoration(
                    labelText: 'Confirm Password',
                    prefixIcon: Icon(Icons.password_outlined),
                    suffixIcon: IconButton(
                      icon: Icon(
                        _hidepass ? Icons.visibility : Icons.visibility_off,
                      ),
                      onPressed: () {
                        setState(() {
                          _hidepass = !_hidepass;
                        });
                      },
                    ),
                    enabledBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(10.0)),
                        borderSide: BorderSide(color: Colors.black, width: 1.0)),
                    focusedBorder: OutlineInputBorder(
                        borderRadius: BorderRadius.all(Radius.circular(20.0)),
                        borderSide: BorderSide(color: Colors.red, width: 1.0)),
                  ),
                  maxLength: 8,
                  validator: _validatePassword,
                ),
              ),
              ElevatedButton(
                onPressed: () async {
                  try {
                    print(email);
                    print(password);
                    _submitform();
                    final newUser = await _auth.createUserWithEmailAndPassword(
                        email: email, password: password);
                    if (newUser != null) {
                      Navigator.pushNamed(context, ChatPage.routename);
                    }
                  }
                  catch (ex) {
                    print(ex);
                    print('WTF');
                  }
                },
                child: Text('Sign Up'),
                style: ElevatedButton.styleFrom(
                    padding: EdgeInsets.symmetric(horizontal: 100, vertical: 20),
                    backgroundColor: Colors.black
                ),
              ),
              TextButton(onPressed: () {
                Navigator.pushNamed(context, LoginPage.routename);
              }, child: Text('Already registered?'))
            ],
          ),
        ),
      ),
    );
  }

  void _submitform() {
    if (_formkey.currentState!.validate()) {
      // returns true if there's not any mistakes
      _formkey.currentState!.save();
    } else {
      print('Form is invalid');
    }
  }

  String? _validateemail(String? value) {
    if (value == null) {
      return "got null";
    } else if (value.isEmpty) {
      return 'This field is required';
    } else if (!_emailcontroller.text.contains('@')) {
      return 'invalid email address';
    } else {
      return null;
    }
  }

  String? _validatePassword(String? value) {
    if (_passcontroller.text.isEmpty) {
      return 'This field is required';
    }
    else if (_passcontroller.text.length < 8) {
      return 'minimum 8 characters required';
    } else {
      return null;
    }
  }
}

app\build.gradle

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:31.1.1')
    implementation 'com.google.firebase:firebase-analytics'
}

apply plugin: "com.google.gms.google-services"

android\build.gradle

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.13'
    }


问:
Hadoop as OLTP feeding Snowflake DataWarehouse
I'm studying Data Warehouse

It's possible to create documents in MongoDB, ETL them in hadoop and feed a Snowflake warehouse?

Does this make any sense?

I researched about this in 2 books:

Big Data Fundamentals: Concepts, Drivers & Techniques
Snowflake: The Definitive Guide


问:
How to save text file in a document directory with Kotlin while using Jetpack with the same format?
I am using following function to save a string as text file in application's directory.

```<code>fun writeText(context: Context, dirName: String, fileName: String, content: String ) {

    val path = context.filesDir
    val letDirectory = File(path, dirName)
    val file = File(letDirectory, fileName)
    val isNewFileCreated :Boolean = file.createNewFile()

    if(isNewFileCreated){
        println("$fileName is created successfully.")
    } else{
        println("$fileName already exists.")
    }

    file.writeText(content)

}
</code>```

But now I need to write a text file in Document directory to attach it to an email if needed.

But I can not find how to write a string as text file in Document directory with Kotlin.

Body:
I am using following function to save a string as text file in application's directory.

fun writeText(context: Context, dirName: String, fileName: String, content: String ) {

    val path = context.filesDir
    val letDirectory = File(path, dirName)
    val file = File(letDirectory, fileName)
    val isNewFileCreated :Boolean = file.createNewFile()

    if(isNewFileCreated){
        println("$fileName is created successfully.")
    } else{
        println("$fileName already exists.")
    }

    file.writeText(content)

}

But now I need to write a text file in Document directory to attach it to an email if needed.

But I can not find how to write a string as text file in Document directory with Kotlin.


问:
Qt state machines: more transition attempts than expected
I have created a simplified example of a state machine transitioning between 2 states on a button click (+ a checkbox showing the active state). I am seeing more calls to the transitions'eventTest method than I expect.

```<code>#include <QtStateMachine/QStateMachine>
#include <QtStateMachine/QSignalTransition>

#include <QtWidgets/QApplication>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QPushButton>

class MySignalTransition : public QSignalTransition
{
public:
    MySignalTransition(QString name, QPushButton* button, QCheckBox* checkBox) :
        QSignalTransition(button, &QAbstractButton::clicked),
        cb(checkBox)
    {
        setObjectName(name);
    }
protected:
    bool eventTest(QEvent* e) override {
        qDebug() << objectName() << "tested on" << e->type() << '|' << cb->isChecked();
        return QSignalTransition::eventTest(e);
    }
private:
    QCheckBox* cb;
};

int main(int argc, char* argv[]) {
    QApplication app(argc, argv);
    app.setQuitOnLastWindowClosed(true);

    QWidget w;
    w.setFixedSize(200, 200);
    QPushButton button(QStringLiteral("Click me"), &w);
    QCheckBox checkbox(&w);
    button.move(10, 80);
    checkbox.move(10, 20);

    QStateMachine m;
    QState s1, s2;
    m.addState(&s1);
    m.addState(&s2);
    m.setInitialState(&s1);

    s1.assignProperty(&checkbox, "checked", false);
    s2.assignProperty(&checkbox, "checked", true);

    //button will be used to make the transition back and forth between states s1 and s2
    MySignalTransition t1("Transition 1", &button, &checkbox), t2("Transition 2", &button, &checkbox);
    t1.setTargetState(&s2);
    t2.setTargetState(&s1);

    s1.addTransition(&t1);
    s2.addTransition(&t2);

    w.show();
    m.start();
    return app.exec();
}
</code>```

On top of the checkbox, I placed a qDebug() << ... to watch when Qt attempts to perform transitions.

The first attempt is right when the state machine starts, before I do any click on the button. I guess (but I am not sure) that this is expected.

The real problem happens when I actually do click on the button. I see:

eventTest is called from the starting state (event->type() == QEvent::None)

eventTest is called from the starting state (event->type() == QEvent::StateMachineSignal)

eventTest is called from the target state (event->type() == QEvent::None)

The one call I am most surprised about is point 1.

What causes the state machine to try the transition again when I click on the button with QEvent::None? This is especially surprising to me because it is always a transition the state machine has already tried (either on start or on the previous click).

If I were to create another transition out of s1 and/or s2, should I be worried that transition could have a higher priority than my signal transitions without any way for me to control it?

Edit

To address @Scheff's cat comment below, I changed the transition class to be:

```<code>class MySignalTransition : public QSignalTransition
{
public:
    MySignalTransition(QString name, QPushButton* button, QCheckBox* checkBox) :
        QSignalTransition(button, &QAbstractButton::clicked),
        cb(checkBox)
    {
        setObjectName(name);
    }
protected:
    bool event(QEvent* e) override {
        return false;
    }
    bool eventTest(QEvent* e) override {
        qDebug() << objectName() << "tested on" << e->type() << '|' << cb->isChecked();
        return transition;
    }
private:
    QCheckBox* cb;
public:
    inline static bool transition = false;
};
</code>```

and right after creating the push button, added:

```<code>QObject::connect(&button, &QPushButton::clicked, []() { MySignalTransition::transition = true; });
</code>```

By doing that, the state machine lets me do 1 click before it starts an infinite loop.
When clicking, MySignalTransition::transition is set to true, then eventTest is called.

With a breakpoint, it is easy to see eventTest is never called with event->type() == QEvent::StateMachineSignal.

To me, this is a clear indication there is more to it than just probing.

First, it would need to do the probing with the actual event, not with a dummy event.

Second, it would not do the transition if the result of the probing was correct, I still should see the 2nd call to eventTest.

Last, I thought maybe the state machine tries to execute as many transitions as it can and will then pass the click signal to whatever other state it lands on.
However, I am not very satisfied by that explanation because the attempt to execute an automatic transition is already done when entering the state (it is the third call to eventTest) and because I think my click should be applied on the state that is active at the very moment I do it, not on just "whatever other state it lands on".

Body:
I have created a simplified example of a state machine transitioning between 2 states on a button click (+ a checkbox showing the active state). I am seeing more calls to the transitions'eventTest method than I expect.

#include <QtStateMachine/QStateMachine>
#include <QtStateMachine/QSignalTransition>

#include <QtWidgets/QApplication>
#include <QtWidgets/QCheckBox>
#include <QtWidgets/QPushButton>

class MySignalTransition : public QSignalTransition
{
public:
    MySignalTransition(QString name, QPushButton* button, QCheckBox* checkBox) :
        QSignalTransition(button, &QAbstractButton::clicked),
        cb(checkBox)
    {
        setObjectName(name);
    }
protected:
    bool eventTest(QEvent* e) override {
        qDebug() << objectName() << "tested on" << e->type() << '|' << cb->isChecked();
        return QSignalTransition::eventTest(e);
    }
private:
    QCheckBox* cb;
};

int main(int argc, char* argv[]) {
    QApplication app(argc, argv);
    app.setQuitOnLastWindowClosed(true);

    QWidget w;
    w.setFixedSize(200, 200);
    QPushButton button(QStringLiteral("Click me"), &w);
    QCheckBox checkbox(&w);
    button.move(10, 80);
    checkbox.move(10, 20);

    QStateMachine m;
    QState s1, s2;
    m.addState(&s1);
    m.addState(&s2);
    m.setInitialState(&s1);

    s1.assignProperty(&checkbox, "checked", false);
    s2.assignProperty(&checkbox, "checked", true);

    //button will be used to make the transition back and forth between states s1 and s2
    MySignalTransition t1("Transition 1", &button, &checkbox), t2("Transition 2", &button, &checkbox);
    t1.setTargetState(&s2);
    t2.setTargetState(&s1);

    s1.addTransition(&t1);
    s2.addTransition(&t2);

    w.show();
    m.start();
    return app.exec();
}

On top of the checkbox, I placed a qDebug() << ... to watch when Qt attempts to perform transitions.

The first attempt is right when the state machine starts, before I do any click on the button. I guess (but I am not sure) that this is expected.

The real problem happens when I actually do click on the button. I see:

eventTest is called from the starting state (event->type() == QEvent::None)

eventTest is called from the starting state (event->type() == QEvent::StateMachineSignal)

eventTest is called from the target state (event->type() == QEvent::None)

The one call I am most surprised about is point 1.

What causes the state machine to try the transition again when I click on the button with QEvent::None? This is especially surprising to me because it is always a transition the state machine has already tried (either on start or on the previous click).

If I were to create another transition out of s1 and/or s2, should I be worried that transition could have a higher priority than my signal transitions without any way for me to control it?

Edit

To address @Scheff's cat comment below, I changed the transition class to be:

class MySignalTransition : public QSignalTransition
{
public:
    MySignalTransition(QString name, QPushButton* button, QCheckBox* checkBox) :
        QSignalTransition(button, &QAbstractButton::clicked),
        cb(checkBox)
    {
        setObjectName(name);
    }
protected:
    bool event(QEvent* e) override {
        return false;
    }
    bool eventTest(QEvent* e) override {
        qDebug() << objectName() << "tested on" << e->type() << '|' << cb->isChecked();
        return transition;
    }
private:
    QCheckBox* cb;
public:
    inline static bool transition = false;
};

and right after creating the push button, added:

QObject::connect(&button, &QPushButton::clicked, []() { MySignalTransition::transition = true; });

By doing that, the state machine lets me do 1 click before it starts an infinite loop.
When clicking, MySignalTransition::transition is set to true, then eventTest is called.

With a breakpoint, it is easy to see eventTest is never called with event->type() == QEvent::StateMachineSignal.

To me, this is a clear indication there is more to it than just probing.

First, it would need to do the probing with the actual event, not with a dummy event.

Second, it would not do the transition if the result of the probing was correct, I still should see the 2nd call to eventTest.

Last, I thought maybe the state machine tries to execute as many transitions as it can and will then pass the click signal to whatever other state it lands on.
However, I am not very satisfied by that explanation because the attempt to execute an automatic transition is already done when entering the state (it is the third call to eventTest) and because I think my click should be applied on the state that is active at the very moment I do it, not on just "whatever other state it lands on".


问:
Formidable gives unhandledRejection: FormidableError: MultipartParser.end(): stream ended unexpectedly: state = START ERROR
So I'm currently trying to create some kind of an API that updates a table in MySQL database and I'm using Formidable package for form data parsing. The update may and may not use a file to replace but in the case where there is no file uploaded. It gives me this error

```<code>error - unhandledRejection: FormidableError: MultipartParser.end(): stream ended unexpectedly: state = START
    at MultipartParser._flush (H:\Files2022\ChronoMedia\chronoapp\node_modules\formidable\src\parsers\Multipart.js:75:9)
    at MultipartParser.final [as _final] (node:internal/streams/transform:133:25)
    at callFinal (node:internal/streams/writable:696:27)
    at prefinish (node:internal/streams/writable:725:7)
    at finishMaybe (node:internal/streams/writable:735:5)
    at MultipartParser.Writable.end (node:internal/streams/writable:633:5)
    at Readable.<anonymous> (H:\Files2022\ChronoMedia\chronoapp\node_modules\formidable\src\Formidable.js:211:24)
    at Readable.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1358:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 1012,
  httpCode: 400
}
</code>```

Here is my code

```<code>const form = new formidable.IncomingForm();

                    form.parse(req, async function (err, fields, files) {
                        if(err) throw err;
                        const {title,content,category,currentPath} = fields;
                        let query = `UPDATE articles set ArticleTitle='${title}', ArticleContent='${content}', ArticleCategory=${category} where ArticleId=${aid}`;
                        try{
                            await connection.execute(query);
                        }catch(err){
                            throw err;
                        }

                        if(files.image){
                            fs.unlink(process.cwd()+"/public"+currentPath);

                            var oldpath = files.image.filepath;
                            fileName = "/public/images/" + uuid4()+"."+MIME_TYPE_MAP[files.image.mimetype];
                            let saveName = fileName.replace('/public','');
                            var newpath = process.cwd()+fileName;
                            fs.copyFile(oldpath, newpath,fs.constants.COPYFILE_EXCL, function (err) {
                                if (err) throw err;
                            });

                            let query = `UPDATE articles set ArticleImage='${saveName}' where ArticleId=${aid}`;
                            try{
                                await connection.execute(query);
                            }catch(err){
                                throw err;
                            }

                        }

                    });
</code>```

I tried looking for a way to make formidable ignores files but it seems not working.

Body:
So I'm currently trying to create some kind of an API that updates a table in MySQL database and I'm using Formidable package for form data parsing. The update may and may not use a file to replace but in the case where there is no file uploaded. It gives me this error

error - unhandledRejection: FormidableError: MultipartParser.end(): stream ended unexpectedly: state = START
    at MultipartParser._flush (H:\Files2022\ChronoMedia\chronoapp\node_modules\formidable\src\parsers\Multipart.js:75:9)
    at MultipartParser.final [as _final] (node:internal/streams/transform:133:25)
    at callFinal (node:internal/streams/writable:696:27)
    at prefinish (node:internal/streams/writable:725:7)
    at finishMaybe (node:internal/streams/writable:735:5)
    at MultipartParser.Writable.end (node:internal/streams/writable:633:5)
    at Readable.<anonymous> (H:\Files2022\ChronoMedia\chronoapp\node_modules\formidable\src\Formidable.js:211:24)
    at Readable.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1358:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 1012,
  httpCode: 400
}

Here is my code

const form = new formidable.IncomingForm();

                    form.parse(req, async function (err, fields, files) {
                        if(err) throw err;
                        const {title,content,category,currentPath} = fields;
                        let query = `UPDATE articles set ArticleTitle='${title}', ArticleContent='${content}', ArticleCategory=${category} where ArticleId=${aid}`;
                        try{
                            await connection.execute(query);
                        }catch(err){
                            throw err;
                        }

                        if(files.image){
                            fs.unlink(process.cwd()+"/public"+currentPath);

                            var oldpath = files.image.filepath;
                            fileName = "/public/images/" + uuid4()+"."+MIME_TYPE_MAP[files.image.mimetype];
                            let saveName = fileName.replace('/public','');
                            var newpath = process.cwd()+fileName;
                            fs.copyFile(oldpath, newpath,fs.constants.COPYFILE_EXCL, function (err) {
                                if (err) throw err;
                            });

                            let query = `UPDATE articles set ArticleImage='${saveName}' where ArticleId=${aid}`;
                            try{
                                await connection.execute(query);
                            }catch(err){
                                throw err;
                            }

                        }

                    });

I tried looking for a way to make formidable ignores files but it seems not working.


问:
Python (merge sort problem) Find number of inversions in array

Writing code to find number of inversions in python using merge sort approach with time complexity of O(n log n).

logic used here :
Top to down => Dividing full array (big problem) to Single elements (small problem)
down to top => conquering part : counting the inversions and arranging sub-array to ascending order

Getting 2 problems in the code:

count is getting 0 after every iteration.

not able to understand how to sort the lower sub array, when they come to up side during the merge procedure.

```<code>def inversionCount(arr,p,q):
    count=0       #.................Problem 1
    if p==q:
        return count

    else:
        mid=(p+(q-p))//2
        countL = inversionCount(arr,p,mid)
        countR = inversionCount(arr,mid+1,q)
        count += countL + countR
        while (p<q):
            if arr[p] > arr[q]:
                count+=1
                p+=1
                q-=1
        # sort the sub-array while down to up process
        new_arr = arr(p,mid) + arr(mid+1,q)     #..................Problem 2
        sorted(arr)
    return count

arr = [70,50,60,10,20,30,80,15]
p=0
q=len(arr)-1
print(inversionCount(arr,p,q))
</code>```

I tried to initialize count at the start of function but I keep getting 0 after every regression
I tried to combine the sub-arrays and sorted it => but not working
I'm not getting where I'm going wrong.

Expected:

Help me with count=0 and sorting of sub array
count=0

```<code>new_arr = arr(p,mid) + arr(mid+1,q)
sorted(arr)
</code>```

or
2. write a new code with similar fashion
or
3. Help me with the conceptual understanding or where I'm going wrong

Body:
Writing code to find number of inversions in python using merge sort approach with time complexity of O(n log n).

logic used here :
Top to down => Dividing full array (big problem) to Single elements (small problem)
down to top => conquering part : counting the inversions and arranging sub-array to ascending order

Getting 2 problems in the code:

count is getting 0 after every iteration.

not able to understand how to sort the lower sub array, when they come to up side during the merge procedure.

def inversionCount(arr,p,q):
    count=0       #.................Problem 1
    if p==q:
        return count

    else:
        mid=(p+(q-p))//2
        countL = inversionCount(arr,p,mid)
        countR = inversionCount(arr,mid+1,q)
        count += countL + countR
        while (p<q):
            if arr[p] > arr[q]:
                count+=1
                p+=1
                q-=1
        # sort the sub-array while down to up process
        new_arr = arr(p,mid) + arr(mid+1,q)     #..................Problem 2
        sorted(arr)
    return count

arr = [70,50,60,10,20,30,80,15]
p=0
q=len(arr)-1
print(inversionCount(arr,p,q))

I tried to initialize count at the start of function but I keep getting 0 after every regression
I tried to combine the sub-arrays and sorted it => but not working
I'm not getting where I'm going wrong.

Expected:

Help me with count=0 and sorting of sub array
count=0

new_arr = arr(p,mid) + arr(mid+1,q)
sorted(arr)

or
2. write a new code with similar fashion
or
3. Help me with the conceptual understanding or where I'm going wrong


问:
Flutter unicreators/mvvm difference between $watch and $watchFor
I just installed unicreators/mvvm flutter library and i confused whats difference between this methods in this library and documents of this library is Chinese i can't understand me

$watch<int>(
  model.timer$,
  builder: (context, value, child) =>
      Text('${pad(value ~/ 100)}.${pad(value % 100)}'),
),
const Text('You have pushed the button this many times:'),
model.$watchFor<int>(
  #counter,
  builder: (context, value, child) =>
      Text('$value', style: Theme.of(context).textTheme.headline4),
)
```
<p>full example:</p>
<pre class="lang-dart prettyprint-override"><code>import 'package:flutter/material.dart';
import 'package:mvvm/mvvm.dart';

/// ViewModel
class MyHomePageViewModel extends ViewModel {
  final timer$ = BindableProperty.$tick(
      duration: const Duration(milliseconds: 10), autostart: true, initial: 0);

  @override
  init() {
    super.init();
    registerProperty(#counter, BindableProperty.$value(initial: 0));
  }

  void incrementCounter() {
    updateValue<int>(#counter, (value) => value + 1);
  }
}

/// View
class MyHomePage extends View<MyHomePageViewModel> {
  final String title;

  const MyHomePage({Key? key, required this.title}) : super(key: key);

  @override
  MyHomePageViewModel createViewModel() => MyHomePageViewModel();

  pad(int value) => '$value'.padLeft(2, '0');

  @override
  Widget build(BuildContext context, MyHomePageViewModel model) {
    return Scaffold(
      appBar: AppBar(title: Text(title)),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            $watch<int>(
              model.timer$,
              builder: (context, value, child) =>
                  Text('${pad(value ~/ 100)}.${pad(value % 100)}'),
            ),
            const Text('You have pushed the button this many times:'),
            model.$watchFor<int>(
              #counter,
              builder: (context, value, child) =>
                  Text('$value', style: Theme.of(context).textTheme.headline4),
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: model.incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}

/// run
void main() => runApp(MaterialApp(
      title: 'Flutter MVVM Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyHomePage(title: 'Flutter MVVM Demo Home Page'),
    ));
</code>```

Body:
I just installed unicreators/mvvm flutter library and i confused whats difference between this methods in this library and documents of this library is Chinese i can't understand me

$watch<int>(
  model.timer$,
  builder: (context, value, child) =>
      Text('${pad(value ~/ 100)}.${pad(value % 100)}'),
),
const Text('You have pushed the button this many times:'),
model.$watchFor<int>(
  #counter,
  builder: (context, value, child) =>
      Text('$value', style: Theme.of(context).textTheme.headline4),
)

full example:

import 'package:flutter/material.dart';
import 'package:mvvm/mvvm.dart';

/// ViewModel
class MyHomePageViewModel extends ViewModel {
  final timer$ = BindableProperty.$tick(
      duration: const Duration(milliseconds: 10), autostart: true, initial: 0);

  @override
  init() {
    super.init();
    registerProperty(#counter, BindableProperty.$value(initial: 0));
  }

  void incrementCounter() {
    updateValue<int>(#counter, (value) => value + 1);
  }
}

/// View
class MyHomePage extends View<MyHomePageViewModel> {
  final String title;

  const MyHomePage({Key? key, required this.title}) : super(key: key);

  @override
  MyHomePageViewModel createViewModel() => MyHomePageViewModel();

  pad(int value) => '$value'.padLeft(2, '0');

  @override
  Widget build(BuildContext context, MyHomePageViewModel model) {
    return Scaffold(
      appBar: AppBar(title: Text(title)),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            $watch<int>(
              model.timer$,
              builder: (context, value, child) =>
                  Text('${pad(value ~/ 100)}.${pad(value % 100)}'),
            ),
            const Text('You have pushed the button this many times:'),
            model.$watchFor<int>(
              #counter,
              builder: (context, value, child) =>
                  Text('$value', style: Theme.of(context).textTheme.headline4),
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: model.incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}

/// run
void main() => runApp(MaterialApp(
      title: 'Flutter MVVM Demo',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const MyHomePage(title: 'Flutter MVVM Demo Home Page'),
    ));


问:
How can i have mutiple format type for a property in ApiProperty Annotation (nestjs)
Example:

```<code>import { ApiProperty, ApiParam } from '@nestjs/swagger';

export class RegisterUserDto {
  @IsEmail()
  @IsNotEmpty()
  @ApiProperty({ type: 'string', format: 'email' })
  email: string;

  @IsString()
  @IsNotEmpty()
  @ApiProperty()
  password: string;

  @IsIP()
  @IsNotEmpty()
  @ApiParam({ type: 'string', format: ['ipv4', 'ipv6'] })
  ipAddress: string;

  @IsString()
  @IsNotEmpty()
  @ApiProperty()
  country: string;

  @IsString()
  @ApiProperty()
  profilePic: string;
}

export class DeleteUserDto {
  @IsString()
  @IsNotEmpty()
  @ApiProperty()
  email: string;
}

export default RegisterUserDto;
</code>```

here I want to define format with ipv4 and ipv6 for ipAddress

type of format in typescript definition is string

I tried looking into documentation of nestjs: https://docs.nestjs.com/openapi/introduction

but didn't find anything regarding this

Body:
Example:

import { ApiProperty, ApiParam } from '@nestjs/swagger';

export class RegisterUserDto {
  @IsEmail()
  @IsNotEmpty()
  @ApiProperty({ type: 'string', format: 'email' })
  email: string;

  @IsString()
  @IsNotEmpty()
  @ApiProperty()
  password: string;

  @IsIP()
  @IsNotEmpty()
  @ApiParam({ type: 'string', format: ['ipv4', 'ipv6'] })
  ipAddress: string;

  @IsString()
  @IsNotEmpty()
  @ApiProperty()
  country: string;

  @IsString()
  @ApiProperty()
  profilePic: string;
}

export class DeleteUserDto {
  @IsString()
  @IsNotEmpty()
  @ApiProperty()
  email: string;
}

export default RegisterUserDto;

here I want to define format with ipv4 and ipv6 for ipAddress

type of format in typescript definition is string

I tried looking into documentation of nestjs: https://docs.nestjs.com/openapi/introduction

but didn't find anything regarding this


问:
How to add Native Full Screen Video Ads in my flutter app?
I'm trying to make an app where I want full screen video ads to display but not like the typical ones with white background and a video holder in between, I want to make something like the ads that pop up in between Youtube Shorts that are full screen, I found Facebook Native Ads but they too have that white background with ad holder in between, Is there any other Ad Network that I can use if it's not possible with Facebook Ad Network? I've just tried Facebook Native Ads as of now</p>


问:
Getting a 'variable not in scope' error when a package is clearly imported
I have a simple program:

module Foo where

import Control.Monad.Trans.Maybe
import Data.Functor

main :: IO ()
main = void $ runMaybeT $ do
  x <- hoistMaybe (Just 5) :: MaybeT IO Int -- Compile error on this line
  pure ()
```
<p>I got an error on the line using <code>hoistMaybe</code> saying</p>
```    Variable not in scope:
      hoistMaybe :: Maybe Int -> MaybeT IO Int
```
<p>This <code>hoistMaybe</code> is clearly present in the <code>transformers</code> package under the <code>Control.Monad.Trans.Maybe</code> module: https://hackage.haskell.org/package/transformers-0.6.0.4/docs/Control-Monad-Trans-Maybe.html#v:hoistMaybe</p>
<p>My Cabal file also listed <code>transformers</code> as a dependency:</p>
<pre class="lang-yaml prettyprint-override"><code>cabal-version: 3.0
build-depends: base
             , transformers
</code>```

What do I need to do to make hoistMaybe in scope for me to call?

My environment if it helps nail down the issue:

```<code>Hardware: Apple MacBook Pro M1 Arm64
OS: MacOS 13.1 Ventura
Compiler toolchain
  - GHCUp v0.1.18.0
  - GHC v9.4.2
  - Cabal v3.8.1.0
</code>```

Body:
I have a simple program:

module Foo where

import Control.Monad.Trans.Maybe
import Data.Functor

main :: IO ()
main = void $ runMaybeT $ do
  x <- hoistMaybe (Just 5) :: MaybeT IO Int -- Compile error on this line
  pure ()

I got an error on the line using hoistMaybe saying

    Variable not in scope:
      hoistMaybe :: Maybe Int -> MaybeT IO Int

This hoistMaybe is clearly present in the transformers package under the Control.Monad.Trans.Maybe module: https://hackage.haskell.org/package/transformers-0.6.0.4/docs/Control-Monad-Trans-Maybe.html#v:hoistMaybe

My Cabal file also listed transformers as a dependency:

cabal-version: 3.0
build-depends: base
             , transformers

What do I need to do to make hoistMaybe in scope for me to call?

My environment if it helps nail down the issue:

Hardware: Apple MacBook Pro M1 Arm64
OS: MacOS 13.1 Ventura
Compiler toolchain
  - GHCUp v0.1.18.0
  - GHC v9.4.2
  - Cabal v3.8.1.0


问:
Is it okay to redirect `XK_KP_Begin` as `XK_Clear` in user implementations?
The numpad key 5 seems to be mapped to XK_KP_Begin by default when num lock is off. And winapi seems to map this key to VK_CLEAR. What is the purpose of XK_KP_Begin? It seems similar to XK_KP_Home if not the same. Is it okay to redirect XK_KP_Begin to XK_Clear in user implementations?

I've tried redirecting XK_KP_Begin to XK_Clear, but I am not sure if that is a good idea.


问:
Unable to pull docker images from harbor through proxy if default_backend is not mentioned
I have a private docker harbour repository which is having docker images and helm charts. I don't want to expose my harbour repository directly. I want to pull docker images and helm charts via HA Proxy server. So here is the my haproxy configuration.

```<code>frontend ashok_registry
  bind 0.0.0.0:8080
  use_backend content-repo if { path_beg -i /repository }

  use_backend gcp-repo if { path_beg -i /mygcp-registry }

  use_backend harbor-repo if { path_beg -i /v2/myharbour-registry }
</code>```

Docker pull command

```<code>docker pull localhost:8080/myharbour-registry/app-images/myimage:1.1.0
Error response from daemon: unauthorized: authorize header needed to send HEAD to repository: authorize header needed to send HEAD to repository
</code>```

Here is my HA Proxy logs, based on url haproxy is redirect to harbor-repo backend. But getting above error.

```<code>Dec 15 11:06:07 ubuntu haproxy[24156]: 127.0.0.1:46896 [15/Dec/2022:11:06:07.006] ashok_registry ashok_registry/<NOSRV> -1/-1/-1/-1/0 503 221 - - SC-- 1/1/0/0/0 0/0 "GET /v2/ HTTP/1.1"
Dec 15 11:06:08 ubuntu haproxy[24156]: 127.0.0.1:46904 [15/Dec/2022:11:06:07.007] ashok_registry harbor-repo/harbor-repo 0/0/1021/369/1390 401 485 - - ---- 1/1/0/0/0 0/0 "HEAD /v2/myharbour-registry/app-images/myimage/manifests/1.1.0 HTTP/1.1"
Dec 15 11:06:09 ubuntu haproxy[24156]: 127.0.0.1:46912 [15/Dec/2022:11:06:08.399] ashok_registry harbor-repo/harbor-repo 0/0/621/278/899 401 637 - - ---- 1/1/0/0/0 0/0 "GET /v2/myharbour-registry/app-images/myimage/manifests/1.1.0 HTTP/1.1"
</code>```

But Same pull command is working fine without any issue when we mention default_backend harbor-repo. What's wrong with my ha proxy configuration.

Body:
I have a private docker harbour repository which is having docker images and helm charts. I don't want to expose my harbour repository directly. I want to pull docker images and helm charts via HA Proxy server. So here is the my haproxy configuration.

frontend ashok_registry
  bind 0.0.0.0:8080
  use_backend content-repo if { path_beg -i /repository }

  use_backend gcp-repo if { path_beg -i /mygcp-registry }

  use_backend harbor-repo if { path_beg -i /v2/myharbour-registry }

Docker pull command

docker pull localhost:8080/myharbour-registry/app-images/myimage:1.1.0
Error response from daemon: unauthorized: authorize header needed to send HEAD to repository: authorize header needed to send HEAD to repository

Here is my HA Proxy logs, based on url haproxy is redirect to harbor-repo backend. But getting above error.

Dec 15 11:06:07 ubuntu haproxy[24156]: 127.0.0.1:46896 [15/Dec/2022:11:06:07.006] ashok_registry ashok_registry/<NOSRV> -1/-1/-1/-1/0 503 221 - - SC-- 1/1/0/0/0 0/0 "GET /v2/ HTTP/1.1"
Dec 15 11:06:08 ubuntu haproxy[24156]: 127.0.0.1:46904 [15/Dec/2022:11:06:07.007] ashok_registry harbor-repo/harbor-repo 0/0/1021/369/1390 401 485 - - ---- 1/1/0/0/0 0/0 "HEAD /v2/myharbour-registry/app-images/myimage/manifests/1.1.0 HTTP/1.1"
Dec 15 11:06:09 ubuntu haproxy[24156]: 127.0.0.1:46912 [15/Dec/2022:11:06:08.399] ashok_registry harbor-repo/harbor-repo 0/0/621/278/899 401 637 - - ---- 1/1/0/0/0 0/0 "GET /v2/myharbour-registry/app-images/myimage/manifests/1.1.0 HTTP/1.1"

But Same pull command is working fine without any issue when we mention default_backend harbor-repo. What's wrong with my ha proxy configuration.


问:
Update attribute in Overpass-API Local server
I have created an overpass API server locally using docker (https://hub.docker.com/r/wiktorn/overpass-api). Suppose I would like to update an attribute of a node/way such as smoothness, surface, speed limit etc. with a new value for a single point or make a bulk update of points in my locally installed server (instead of the public server), how does one do that? Any feedback is appreciated.</p>


问:
How to make Java game more efficient?
I have been working on a flappy bird clone so I can get more practice programming. Everything in the game works, however the game has frame skips and lag drops, and I do not know how to make Java programs run more smoothly. Am I supposed to measure the amount of time a method takes and try to shorten that, or do I do something else? I have seen people explain how to program Java games, but there is hardly anything on improving the performance. Any advice would be helpful. Thank you.

Hazards class

```<code>package entity;

import java.util.ArrayList;

public class Hazards {

    public ArrayList<Horizontal> hors;
    public ArrayList<Vertical> verts;

    public Hazards(int width, int height, int thickness) {

        hors = new ArrayList<Horizontal>();
        hors.add(new Horizontal(0, 0, width, thickness));
        hors.add(new Horizontal(0, height-thickness, width, thickness));

        verts = new ArrayList<Vertical>();

    }

}
</code>```

Horizontal class

```<code>package entity;

import java.awt.Rectangle;

public class Horizontal {

    public int xPos, yPos, width, height;
    public Rectangle bounds;

    public Horizontal(int x, int y, int w, int h) {
        this.xPos = x;
        this.yPos = y;
        this.width = w;
        this.height = h;
        this.bounds = new Rectangle(x, y, w, h);
    }

    public void updateBounds(int x, int y, int w, int h) {
        this.xPos = x;
        this.yPos = y;
        this.width = w;
        this.height = h;
        this.bounds = new Rectangle(x, y, w, h);
    }

}
</code>```

Vertical class

```<code>package entity;

import java.awt.Rectangle;
import java.util.Random;

public class Vertical {

    public int xPos, width, gapSize, gapPos;
    public boolean scoredOn = false;
    public Rectangle top, bottom;

    public Vertical(int xPos, int width, int roofHeight, int floorHeight, int gapSize) {
        this.xPos = xPos;
        this.width = width;

        this.gapPos = new Random().nextInt(floorHeight - gapSize) + roofHeight;

        this.top = new Rectangle();
        this.bottom = new Rectangle();
        this.top.setBounds(xPos, 0, width, gapPos);
        this.bottom.setBounds(xPos, gapPos + gapSize, width, floorHeight - roofHeight + top.height + gapSize);

    }

}
</code>```

Content class

```<code>package main;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Rectangle;

import javax.swing.JPanel;

public class Content extends JPanel {

    private static final long serialVersionUID = 1L;

    private Engine e;
    private Rectangle bounds;

    public Content(Engine engine) {
        e = engine;
    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.clearRect(0, 0, this.getWidth(), this.getHeight());

        // Roof and floor
        g.setColor(Color.black);
        for (int x = 0; x < e.e.hors.size(); x++) {
            bounds = e.e.hors.get(x).bounds;
            g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
        }

        // Pipes
        g.setColor(Color.black);
        for(int x = 0; x < e.e.verts.size(); x++) {
            bounds = e.e.verts.get(x).top;
            g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
            bounds = e.e.verts.get(x).bottom;
            g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
        }

        // Player
        g.setColor(Color.black);
        g.fillRect((int) e.p.xPos, (int) e.p.yPos, e.p.size, e.p.size);

        // Score
        g.setColor(Color.blue);
        g.setFont(new Font("Monospaced", Font.PLAIN, 40));
        g.drawString(Integer.toString(e.p.score), e.width/2, 80);
    }

}
</code>```

Engine class

```<code>package main;

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import entity.Hazards;
import entity.Vertical;
import screen.TitleScreen;

public class Engine implements Runnable {

    public JFrame f;
    public String title = "Flappy Bird";
    public int width = 500, height = 500;
    public Content c;

    public boolean running = false;
    public boolean playing = false;
    public Thread t;

    public Player p;

    public Hazards e;

    public TitleScreen ts;

    public JPanel mainPanel;

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                Engine e = new Engine();
                e.execute();
            }

        });
    }

    public void execute() {

        ts = new TitleScreen(width, height);

        e = new Hazards(width, height, 30);

        p = new Player(this);

        c = new Content(this);
        c.setPreferredSize(new Dimension(width, height));
        c.setLayout(null);
        c.addKeyListener(p);

        mainPanel = new JPanel();
        mainPanel.setPreferredSize(new Dimension(width, height));
        mainPanel.setLayout(null);

        f = new JFrame();
        f.setTitle(title);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setResizable(false);
        f.add(c);
        // f.add(mainPanel);
        f.pack();
        f.createBufferStrategy(2);
        f.setLayout(null);
        f.setLocationRelativeTo(null);
        f.setVisible(true);

        c.requestFocus();

        //ts.setScreen(mainPanel);

        start();

    }

    public synchronized void start() {
        if (running)
            return;
        running = true;
        t = new Thread(this);
        t.start();
    }

    public synchronized void stop() {
        if (!running)
            return;
        running = false;
        try {
            t.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public void run() {

            long lastime = System.nanoTime();
            double AmountOfTicks = 60;
            double ns = 1000000000 / AmountOfTicks;
            double delta = 0;
            int tick = 0;

            while (running) {

                long now = System.nanoTime();
                delta += (now - lastime) / ns;
                lastime = now;

                if (delta >= 1) {
                    // Call all updates here
                    if (playing) {
                        p.updatePos();
                        tick++;
                        if (tick == 60) {
                            tick = 0;
                            p.distance += p.speed;
                            System.out.println(p.distance);
                            if ((p.distance % 4) == 0) {
                                System.out.println("Making new pipes-----------------------------------------------------");
                                e.verts.add(new Vertical(600, 10, 30, height - 30, 100));
                            }
                        }
                        for (int x = 0; x < e.verts.size(); x++) {
                            e.verts.get(x).top.x -= p.speed;
                            e.verts.get(x).bottom.x -= p.speed;

                            if(e.verts.get(x).top.x<-50) {
                                e.verts.remove(x);
                                System.out.println("removed a pipe");
                            }

                            if(p.xPos>e.verts.get(x).top.x && !e.verts.get(x).scoredOn) {
                                e.verts.get(x).scoredOn = true;
                                p.score++;
                            }

                        }
                    }

                    mainPanel.revalidate();
                    mainPanel.repaint();
                    f.revalidate();
                    f.repaint();

                    delta--;

                }

        }

    }

}
</code>```

Player class

```<code>package main;

import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class Player implements KeyListener {

    public int size = 10;
    public double xPos = 50;
    public double yPos = 240;
    public double gravity = 3.4;
    public double jumpForce = 16.6;
    public double weight = 1;
    public int speed = 2;
    public int score = 0;
    public int distance = 0;

    public boolean jumping = false;
    public double jumpTime = 10;
    public int timed = 0;

    public Rectangle bounds, temp, top, bottom;

    public Engine en;

    public Player(Engine engine) {
        en = engine;
        bounds = new Rectangle((int)xPos, (int)yPos, size, size);
    }

    public void keyTyped(KeyEvent e) {
    }

    public void keyPressed(KeyEvent e) {
        if (e.getKeyCode() == KeyEvent.VK_W && en.playing) {
            jumping = true;
        } else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
            en.playing = !en.playing;
        }

        if(jumping) {
            timed = 0;
            jumpForce = 16.6;
        }
    }

    public void keyReleased(KeyEvent e) {
    }

    public void updatePos() {

        // collide with floor or ceiling
        for(int x = 0; x < en.e.hors.size(); x++) {
            temp = en.e.hors.get(x).bounds;
            if(bounds.intersects(temp)) {
                en.playing = false;
                jumping = false;
                timed = 0;
                jumpForce = 0;
                yPos = 240;
                score = 0;
                en.e.verts.clear();
                distance = 0;
                gravity = 3.8;
            }
        }

        // collide with pipe
        for(int x =0; x <en.e.verts.size();x++) {
            top = en.e.verts.get(x).top;
            bottom = en.e.verts.get(x).bottom;
            if(bounds.intersects(top)||bounds.intersects(bottom)) {
                en.playing = false;
                jumping = false;
                timed = 0;
                jumpForce = 0;
                yPos = 240;
                score = 0;
                gravity =3.4;
                en.e.verts.clear();
                distance = 0;
            }
        }

        if (jumping && en.playing) {
            gravity = 3.4;
            yPos -= jumpForce;
            jumpForce -= weight;
            if (jumpForce == 0) {
                jumping = false;
                jumpForce = 16.6;
            }
        }

        //if(!jumping && en.playing) {
            gravity += 0.1;
        //}

        System.out.println(gravity);
        yPos += gravity;
        bounds.setBounds((int)xPos, (int)yPos, size, size);

    }

}
</code>```

Title: How to make Java game more efficient?

Body:
I have been working on a flappy bird clone so I can get more practice programming. Everything in the game works, however the game has frame skips and lag drops, and I do not know how to make Java programs run more smoothly. Am I supposed to measure the amount of time a method takes and try to shorten that, or do I do something else? I have seen people explain how to program Java games, but there is hardly anything on improving the performance. Any advice would be helpful. Thank you.

Hazards class

package entity;

import java.util.ArrayList;

public class Hazards {

    public ArrayList<Horizontal> hors;
    public ArrayList<Vertical> verts;

    public Hazards(int width, int height, int thickness) {

        hors = new ArrayList<Horizontal>();
        hors.add(new Horizontal(0, 0, width, thickness));
        hors.add(new Horizontal(0, height-thickness, width, thickness));

        verts = new ArrayList<Vertical>();

    }

}

Horizontal class

package entity;

import java.awt.Rectangle;

public class Horizontal {

    public int xPos, yPos, width, height;
    public Rectangle bounds;

    public Horizontal(int x, int y, int w, int h) {
        this.xPos = x;
        this.yPos = y;
        this.width = w;
        this.height = h;
        this.bounds = new Rectangle(x, y, w, h);
    }

    public void updateBounds(int x, int y, int w, int h) {
        this.xPos = x;
        this.yPos = y;
        this.width = w;
        this.height = h;
        this.bounds = new Rectangle(x, y, w, h);
    }

}

Vertical class

package entity;

import java.awt.Rectangle;
import java.util.Random;

public class Vertical {

    public int xPos, width, gapSize, gapPos;
    public boolean scoredOn = false;
    public Rectangle top, bottom;

    public Vertical(int xPos, int width, int roofHeight, int floorHeight, int gapSize) {
        this.xPos = xPos;
        this.width = width;

        this.gapPos = new Random().nextInt(floorHeight - gapSize) + roofHeight;

        this.top = new Rectangle();
        this.bottom = new Rectangle();
        this.top.setBounds(xPos, 0, width, gapPos);
        this.bottom.setBounds(xPos, gapPos + gapSize, width, floorHeight - roofHeight + top.height + gapSize);

    }

}

Content class

package main;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Rectangle;

import javax.swing.JPanel;

public class Content extends JPanel {

    private static final long serialVersionUID = 1L;

    private Engine e;
    private Rectangle bounds;

    public Content(Engine engine) {
        e = engine;
    }

    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.clearRect(0, 0, this.getWidth(), this.getHeight());

        // Roof and floor
        g.setColor(Color.black);
        for (int x = 0; x < e.e.hors.size(); x++) {
            bounds = e.e.hors.get(x).bounds;
            g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
        }

        // Pipes
        g.setColor(Color.black);
        for(int x = 0; x < e.e.verts.size(); x++) {
            bounds = e.e.verts.get(x).top;
            g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
            bounds = e.e.verts.get(x).bottom;
            g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
        }

        // Player
        g.setColor(Color.black);
        g.fillRect((int) e.p.xPos, (int) e.p.yPos, e.p.size, e.p.size);

        // Score
        g.setColor(Color.blue);
        g.setFont(new Font("Monospaced", Font.PLAIN, 40));
        g.drawString(Integer.toString(e.p.score), e.width/2, 80);
    }

}

Engine class

package main;

import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import entity.Hazards;
import entity.Vertical;
import screen.TitleScreen;

public class Engine implements Runnable {

    public JFrame f;
    public String title = "Flappy Bird";
    public int width = 500, height = 500;
    public Content c;

    public boolean running = false;
    public boolean playing = false;
    public Thread t;

    public Player p;

    public Hazards e;

    public TitleScreen ts;

    public JPanel mainPanel;

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                Engine e = new Engine();
                e.execute();
            }

        });
    }

    public void execute() {

        ts = new TitleScreen(width, height);

        e = new Hazards(width, height, 30);

        p = new Player(this);

        c = new Content(this);
        c.setPreferredSize(new Dimension(width, height));
        c.setLayout(null);
        c.addKeyListener(p);

        mainPanel = new JPanel();
        mainPanel.setPreferredSize(new Dimension(width, height));
        mainPanel.setLayout(null);

        f = new JFrame();
        f.setTitle(title);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setResizable(false);
        f.add(c);
        // f.add(mainPanel);
        f.pack();
        f.createBufferStrategy(2);
        f.setLayout(null);
        f.setLocationRelativeTo(null);
        f.setVisible(true);

        c.requestFocus();

        //ts.setScreen(mainPanel);

        start();

    }

    public synchronized void start() {
        if (running)
            return;
        running = true;
        t = new Thread(this);
        t.start();
    }

    public synchronized void stop() {
        if (!running)
            return;
        running = false;
        try {
            t.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public void run() {

            long lastime = System.nanoTime();
            double AmountOfTicks = 60;
            double ns = 1000000000 / AmountOfTicks;
            double delta = 0;
            int tick = 0;

            while (running) {

                long now = System.nanoTime();
                delta += (now - lastime) / ns;
                lastime = now;

                if (delta >= 1) {
                    // Call all updates here
                    if (playing) {
                        p.updatePos();
                        tick++;
                        if (tick == 60) {
                            tick = 0;
                            p.distance += p.speed;
                            System.out.println(p.distance);
                            if ((p.distance % 4) == 0) {
                                System.out.println("Making new pipes-----------------------------------------------------");
                                e.verts.add(new Vertical(600, 10, 30, height - 30, 100));
                            }
                        }
                        for (int x = 0; x < e.verts.size(); x++) {
                            e.verts.get(x).top.x -= p.speed;
                            e.verts.get(x).bottom.x -= p.speed;

                            if(e.verts.get(x).top.x<-50) {
                                e.verts.remove(x);
                                System.out.println("removed a pipe");
                            }

                            if(p.xPos>e.verts.get(x).top.x && !e.verts.get(x).scoredOn) {
                                e.verts.get(x).scoredOn = true;
                                p.score++;
                            }

                        }
                    }

                    mainPanel.revalidate();
                    mainPanel.repaint();
                    f.revalidate();
                    f.repaint();

                    delta--;

                }

        }

    }

}

Player class

package main;

import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class Player implements KeyListener {

    public int size = 10;
    public double xPos = 50;
    public double yPos = 240;
    public double gravity = 3.4;
    public double jumpForce = 16.6;
    public double weight = 1;
    public int speed = 2;
    public int score = 0;
    public int distance = 0;

    public boolean jumping = false;
    public double jumpTime = 10;
    public int timed = 0;

    public Rectangle bounds, temp, top, bottom;

    public Engine en;

    public Player(Engine engine) {
        en = engine;
        bounds = new Rectangle((int)xPos, (int)yPos, size, size);
    }

    public void keyTyped(KeyEvent e) {
    }

    public void keyPressed(KeyEvent e) {
        if (e.getKeyCode() == KeyEvent.VK_W && en.playing) {
            jumping = true;
        } else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
            en.playing = !en.playing;
        }

        if(jumping) {
            timed = 0;
            jumpForce = 16.6;
        }
    }

    public void keyReleased(KeyEvent e) {
    }

    public void updatePos() {

        // collide with floor or ceiling
        for(int x = 0; x < en.e.hors.size(); x++) {
            temp = en.e.hors.get(x).bounds;
            if(bounds.intersects(temp)) {
                en.playing = false;
                jumping = false;
                timed = 0;
                jumpForce = 0;
                yPos = 240;
                score = 0;
                en.e.verts.clear();
                distance = 0;
                gravity = 3.8;
            }
        }

        // collide with pipe
        for(int x =0; x <en.e.verts.size();x++) {
            top = en.e.verts.get(x).top;
            bottom = en.e.verts.get(x).bottom;
            if(bounds.intersects(top)||bounds.intersects(bottom)) {
                en.playing = false;
                jumping = false;
                timed = 0;
                jumpForce = 0;
                yPos = 240;
                score = 0;
                gravity =3.4;
                en.e.verts.clear();
                distance = 0;
            }
        }

        if (jumping && en.playing) {
            gravity = 3.4;
            yPos -= jumpForce;
            jumpForce -= weight;
            if (jumpForce == 0) {
                jumping = false;
                jumpForce = 16.6;
            }
        }

        //if(!jumping && en.playing) {
            gravity += 0.1;
        //}

        System.out.println(gravity);
        yPos += gravity;
        bounds.setBounds((int)xPos, (int)yPos, size, size);

    }

}


问:
Underline text in mapbox cluster map
I am trying to underline the text in the mapbox cluster map (https://www.mapbox.com/mapbox-gl-js/example/cluster/), but I can't figure out how.

Here is the relevant code piece:

```<code>map.addLayer({
    id: "cluster-count",
    type: "symbol",
    source: "grundbuch",
    filter: ["has", "point_count"],
    layout: {
        "text-field": "{point_count_abbreviated}",
        "text-font": ["DIN Offc Pro Medium", "Arial Unicode MS Bold"],
        "text-size": 12
    }
});
</code>```

Does anybody know how to do this? I would like to underline the text

Title: Underline text in mapbox cluster map

Body:
I am trying to underline the text in the mapbox cluster map (https://www.mapbox.com/mapbox-gl-js/example/cluster/), but I can't figure out how.

Here is the relevant code piece:

map.addLayer({
    id: "cluster-count",
    type: "symbol",
    source: "grundbuch",
    filter: ["has", "point_count"],
    layout: {
        "text-field": "{point_count_abbreviated}",
        "text-font": ["DIN Offc Pro Medium", "Arial Unicode MS Bold"],
        "text-size": 12
    }
});

Does anybody know how to do this? I would like to underline the text


问:
When adding a record in Django admin, when a field is selected, I want the other field to come automatically depending on it
In order to make the problem easier to understand, I am writing the codes as short as possible here.

```<code>models.py:
----------
class Room(models.Model):
    room_no = models.CharField()

class Unit(models.Model):
    unit_name = models.CharField()
    room = models.ManyToManyField(Room, related_name='roomunit')

class Employee(models.Model):
    employee_name = models.CharField()
    unit = models.ForeignKey(Unit)
    room = models.ForeignKey(Room)
</code>```
```<code>admin.py:
---------
class EmployeeAdmin(admin.ModelAdmin):
    list_display('employee_name', 'unit', 'room',)

class RoomAdmin(admin.ModelAdmin):
    list_display=('room_no',)

class UnitAdmin(admin.ModelAdmin):
    list_display=('unit_name', 'roomno',)

    def roomno(self,obj):
        r = Room.objects.get(roomunit=obj)
        return r

admin.site.register(Employee, EmployeeAdmin)
admin.site.register(Unit, UnitAdmin)
admin.site.register(Room, RoomAdmin)
</code>```

Sample data were entered for the room and the unit according to the relationship between them.
There is ManyToMany relation between Unit and Room.

Screenshot of Employee add form.
Screenshot of the form

This is what i want to do:

When adding a new employee to the employee add form, when I select the unit name, I want the room_no associated with it to appear automatically

Body:
In order to make the problem easier to understand, I am writing the codes as short as possible here.

models.py:
----------
class Room(models.Model):
    room_no = models.CharField()

class Unit(models.Model):
    unit_name = models.CharField()
    room = models.ManyToManyField(Room, related_name='roomunit')

class Employee(models.Model):
    employee_name = models.CharField()
    unit = models.ForeignKey(Unit)
    room = models.ForeignKey(Room)

admin.py:
---------
class EmployeeAdmin(admin.ModelAdmin):
    list_display('employee_name', 'unit', 'room',)

class RoomAdmin(admin.ModelAdmin):
    list_display=('room_no',)

class UnitAdmin(admin.ModelAdmin):
    list_display=('unit_name', 'roomno',)

    def roomno(self,obj):
        r = Room.objects.get(roomunit=obj)
        return r

admin.site.register(Employee, EmployeeAdmin)
admin.site.register(Unit, UnitAdmin)
admin.site.register(Room, RoomAdmin)

Sample data were entered for the room and the unit according to the relationship between them.
There is ManyToMany relation between Unit and Room.

Screenshot of Employee add form.
Screenshot of the form

This is what i want to do:

When adding a new employee to the employee add form, when I select the unit name, I want the room_no associated with it to appear automatically


问:
Why is PaddleOCR CRNN rec_algorithom recognizing text with no match at all?
Here, I am using DB as the detection algorithm and CRNN as the recognition algorithm. The texts I want to detect are English words.

The texts I am getting from it are as follows-

'text': ['MBF>KS','K>?','MBF>K1','=N:EEBO>','?E:LA','O><<>EF:Q','?EHPF:Q','BGBM,'M@<','FB<HGMKHE','?E:LA','?K>JN>G<R','008','I>G']

Actual Texts (that I should get) are as follows-

'Timer 2', 'Ref. Pointer', 'Timer 1', 'Dual Live', 'Flash', 'VesselMax', 'FlowMax', 'Init.', 'TGC', 'MI Control', 'Flash Frame', 'Frequency', '0.08', 'Pen'


问:
How do we map the API resource to the existing API Gateway and exsisting lambda authorizer (ARN)in AWS CDK python..?
I need to map the API resource to the existing APIgateway,when i do that what eventually will happen is that APIgateway will have one URL,if you hit the url, automatically i will get the new environment.

I have a working environment, but i need to do the intergration part, i need to map the API resource to the existing APIgateway,when i do that what eventually will happen is that APIgateway will have one URL,if you hit the url, automatically i wil get the new environment. The lambda Authorizer we are not creating the authorizer, we already have one, i just need to bind the ARN no with the resource.


问:
Docker variable in choco command
I have a docker run command that runs a chocolatey command. I am trying to use a variable in the choco command but getting an error. Hard coding the value of the variable in the command works.

This fails:

```<code>ARG azurecli_version="2.43.0"
RUN powershell choco feature enable -n allowGlobalConfirmation; choco install azure-cli --version ${azurecli_version} --no-progress
</code>```

Error:

```<code>'--no-progress' is not a valid version string.
</code>```

This works:

```<code>RUN powershell choco feature enable -n allowGlobalConfirmation; choco install azure-cli --version 2.43.0 --no-progress
</code>```

Title: Docker variable in choco command

Body:
I have a docker run command that runs a chocolatey command. I am trying to use a variable in the choco command but getting an error. Hard coding the value of the variable in the command works.

This fails:

ARG azurecli_version="2.43.0"
RUN powershell choco feature enable -n allowGlobalConfirmation; choco install azure-cli --version ${azurecli_version} --no-progress

Error:

'--no-progress' is not a valid version string.

This works:

RUN powershell choco feature enable -n allowGlobalConfirmation; choco install azure-cli --version 2.43.0 --no-progress


问:
write a query to select first record with X status and 2nd record with V or M status with same client id in both records?

client id
status

1234
X

1234
X

1234
X

12344
X

12344
V

12345
X

12345
M

client id
status

12344
X

12344
V

12345
X

12345
M


问:
Cannot access apache server from foreign ip address
I have a site running on my computer using Apache 2.4 which I can easily access by using my local ipv4 address and respective port 80. The port 80 is bound to port 22*** using portmap.io and is configured with OpenVpn/tcp on my computer.I have allowed access to Apache HTTP server and Apache Server Monitor through the firewall.I have also increased keepAlive timeout in apche server to 600s, max connections.i have Listen 80 and LISTEN 22*** and ServerName as http://awm-22***.portmap.host:22*** in my httpd.conf file.You can look into for more options here.
Apache handler configuration

I am using PHP as backend language.

Since the port 80 is bound to port 22470, whenever I try access my site from another device(which also uses the same wifi network as the computer running the server) using the local ipv4 address of my computer(which is running the server) and port 80 i.e
192.168..:80, it automatically redirects the browser to 192.168..:22*** and I can access my site with no difficuty. Access log in apcache server:

```<code>
    192.168.**.** - - [15/Dec/2022:10:08:02 +0530] "GET /abc%20xyz%20klm/ HTTP/1.1" 200 12049
    192.168.**.** - - [15/Dec/2022:10:08:02 +0530] "GET /SPR/b/get_captcha.php?rand=29842778 HTTP/1.1" 200 4057

</code>```

But when I try access the same site from another device(which also uses the same wifi network as the computer running the server) using the ipv4 address provided by OpenVpn to my computer(which is running the server):10.9..* and port 80 i.e 10.9..*:80, it shows TOOK TOO LONG TO RESPPOND error on the browser.But the browser's header has the following:

```<code>
    http://10.9.**.**4:22470/abc%20xyz%20klm/

</code>```

Then why is it not loading the page. No log in apache access log file.

When I try access the same site from another device(which also uses the same wifi network as the computer running the server) using the url provided to me by portmap.io i.e: http://awm-22***.portmap.host:22***/,
The server takes too long to respond error is shown in the browser.
Access log in apcache server:

```<code>
    10.9.0.1 - - [15/Dec/2022:10:21:33 +0530] "GET / HTTP/1.0" 302 -
    10.9.0.1 - - [15/Dec/2022:10:21:34 +0530] "GET /abc%20xyz%20klm HTTP/1.0" 301 256

</code>```

OpenVpn Log:

```<code>
   Thu Dec 15 10:32:30 2022 SIGHUP[hard,] received, process restarting
   Thu Dec 15 10:32:30 2022 --cipher is not set. Previous OpenVPN version defaulted to BF-CBC as fallback when cipher negotiation failed in this case. If you need this fallback please add '--data-ciphers-fallback BF-CBC' to your configuration and/or add BF-CBC to --data-ciphers.
   Thu Dec 15 10:32:30 2022 OpenVPN 2.5.7 [git:release/2.5/3d792ae9557b959e] Windows-MSVC [SSL (OpenSSL)] [LZO] [LZ4] [PKCS11] [AEAD] built on Oct 28 2022
   Thu Dec 15 10:32:30 2022 Windows version 10.0 (Windows 10 or greater) 64bit
   Thu Dec 15 10:32:30 2022 library versions: OpenSSL 1.1.1o  3 May 2022, LZO 2.10
   Thu Dec 15 10:32:35 2022 TCP/UDP: Preserving recently used remote address: [AF_INET]193.161.193.99:1194
   Thu Dec 15 10:32:35 2022 Attempting to establish TCP connection with [AF_INET]193.161.193.99:1194 [nonblock]
   Thu Dec 15 10:32:35 2022 TCP connection established with [AF_INET]193.161.193.99:1194
   Thu Dec 15 10:32:35 2022 TCP_CLIENT link local: (not bound)
   Thu Dec 15 10:32:35 2022 TCP_CLIENT link remote: [AF_INET]193.161.193.99:1194
   Thu Dec 15 10:32:41 2022 [193.161.193.99] Peer Connection Initiated with [AF_INET]193.161.193.99:1194
   Thu Dec 15 10:32:42 2022 WARNING: INSECURE cipher (BF-CBC) with block size less than 128 bit (64 bit).  This allows attacks like SWEET32.  Mitigate by using a --cipher with a larger block size (e.g. AES-256-CBC). Support for these insecure ciphers will be removed in OpenVPN 2.7.
   Thu Dec 15 10:32:42 2022 WARNING: INSECURE cipher (BF-CBC) with block size less than 128 bit (64 bit).  This allows attacks like SWEET32.  Mitigate by using a --cipher with a larger block size (e.g. AES-256-CBC). Support for these insecure ciphers will be removed in OpenVPN 2.7.
   Thu Dec 15 10:32:42 2022 WARNING: cipher with small block size in use, reducing reneg-bytes to 64MB to mitigate SWEET32 attacks.
   Thu Dec 15 10:32:42 2022 open_tun
   Thu Dec 15 10:32:42 2022 tap-windows6 device [OpenVPN TAP-Windows6] opened
   Thu Dec 15 10:32:42 2022 Notified TAP-Windows driver to set a DHCP IP/netmask of 10.9.**.234/255.255.255.252 on interface {798F492A-574C-4BC6-87C5-A62C6D058EC1} [DHCP-serv: 10.9.**.233, lease-time: 31536000]
   Thu Dec 15 10:32:42 2022 Successful ARP Flush on interface [12] {798F492A-574C-4BC6-87C5-A62C6D058EC1}
   Thu Dec 15 10:32:42 2022 IPv4 MTU set to 1500 on interface 12 using service

</code>```

These are my firewall rules:

Inbound rules

Inbound rule for Port 80
Outbound rules

Firewall monitoring Domain and Private Profiles

Firewall monitoring Public Profile

What is causing the problem? Any solution will be of great help.  Thanks in advance.

Body:
I have a site running on my computer using Apache 2.4 which I can easily access by using my local ipv4 address and respective port 80. The port 80 is bound to port 22*** using portmap.io and is configured with OpenVpn/tcp on my computer.I have allowed access to Apache HTTP server and Apache Server Monitor through the firewall.I have also increased keepAlive timeout in apche server to 600s, max connections.i have Listen 80 and LISTEN 22*** and ServerName as http://awm-22***.portmap.host:22*** in my httpd.conf file.You can look into for more options here.
Apache handler configuration

I am using PHP as backend language.

Since the port 80 is bound to port 22470, whenever I try access my site from another device(which also uses the same wifi network as the computer running the server) using the local ipv4 address of my computer(which is running the server) and port 80 i.e
192.168..:80, it automatically redirects the browser to 192.168..:22*** and I can access my site with no difficuty. Access log in apcache server:

    192.168.**.** - - [15/Dec/2022:10:08:02 +0530] "GET /abc%20xyz%20klm/ HTTP/1.1" 200 12049
    192.168.**.** - - [15/Dec/2022:10:08:02 +0530] "GET /SPR/b/get_captcha.php?rand=29842778 HTTP/1.1" 200 4057

But when I try access the same site from another device(which also uses the same wifi network as the computer running the server) using the ipv4 address provided by OpenVpn to my computer(which is running the server):10.9..* and port 80 i.e 10.9..*:80, it shows TOOK TOO LONG TO RESPPOND error on the browser.But the browser's header has the following:

    http://10.9.**.**4:22470/abc%20xyz%20klm/

Then why is it not loading the page. No log in apache access log file.

When I try access the same site from another device(which also uses the same wifi network as the computer running the server) using the url provided to me by portmap.io i.e: http://awm-22***.portmap.host:22***/,
The server takes too long to respond error is shown in the browser.
Access log in apcache server:

    10.9.0.1 - - [15/Dec/2022:10:21:33 +0530] "GET / HTTP/1.0" 302 -
    10.9.0.1 - - [15/Dec/2022:10:21:34 +0530] "GET /abc%20xyz%20klm HTTP/1.0" 301 256

OpenVpn Log:

   Thu Dec 15 10:32:30 2022 SIGHUP[hard,] received, process restarting
   Thu Dec 15 10:32:30 2022 --cipher is not set. Previous OpenVPN version defaulted to BF-CBC as fallback when cipher negotiation failed in this case. If you need this fallback please add '--data-ciphers-fallback BF-CBC' to your configuration and/or add BF-CBC to --data-ciphers.
   Thu Dec 15 10:32:30 2022 OpenVPN 2.5.7 [git:release/2.5/3d792ae9557b959e] Windows-MSVC [SSL (OpenSSL)] [LZO] [LZ4] [PKCS11] [AEAD] built on Oct 28 2022
   Thu Dec 15 10:32:30 2022 Windows version 10.0 (Windows 10 or greater) 64bit
   Thu Dec 15 10:32:30 2022 library versions: OpenSSL 1.1.1o  3 May 2022, LZO 2.10
   Thu Dec 15 10:32:35 2022 TCP/UDP: Preserving recently used remote address: [AF_INET]193.161.193.99:1194
   Thu Dec 15 10:32:35 2022 Attempting to establish TCP connection with [AF_INET]193.161.193.99:1194 [nonblock]
   Thu Dec 15 10:32:35 2022 TCP connection established with [AF_INET]193.161.193.99:1194
   Thu Dec 15 10:32:35 2022 TCP_CLIENT link local: (not bound)
   Thu Dec 15 10:32:35 2022 TCP_CLIENT link remote: [AF_INET]193.161.193.99:1194
   Thu Dec 15 10:32:41 2022 [193.161.193.99] Peer Connection Initiated with [AF_INET]193.161.193.99:1194
   Thu Dec 15 10:32:42 2022 WARNING: INSECURE cipher (BF-CBC) with block size less than 128 bit (64 bit).  This allows attacks like SWEET32.  Mitigate by using a --cipher with a larger block size (e.g. AES-256-CBC). Support for these insecure ciphers will be removed in OpenVPN 2.7.
   Thu Dec 15 10:32:42 2022 WARNING: INSECURE cipher (BF-CBC) with block size less than 128 bit (64 bit).  This allows attacks like SWEET32.  Mitigate by using a --cipher with a larger block size (e.g. AES-256-CBC). Support for these insecure ciphers will be removed in OpenVPN 2.7.
   Thu Dec 15 10:32:42 2022 WARNING: cipher with small block size in use, reducing reneg-bytes to 64MB to mitigate SWEET32 attacks.
   Thu Dec 15 10:32:42 2022 open_tun
   Thu Dec 15 10:32:42 2022 tap-windows6 device [OpenVPN TAP-Windows6] opened
   Thu Dec 15 10:32:42 2022 Notified TAP-Windows driver to set a DHCP IP/netmask of 10.9.**.234/255.255.255.252 on interface {798F492A-574C-4BC6-87C5-A62C6D058EC1} [DHCP-serv: 10.9.**.233, lease-time: 31536000]
   Thu Dec 15 10:32:42 2022 Successful ARP Flush on interface [12] {798F492A-574C-4BC6-87C5-A62C6D058EC1}
   Thu Dec 15 10:32:42 2022 IPv4 MTU set to 1500 on interface 12 using service

These are my firewall rules:

Inbound rules

Inbound rule for Port 80
Outbound rules

Firewall monitoring Domain and Private Profiles

Firewall monitoring Public Profile

What is causing the problem? Any solution will be of great help.  Thanks in advance.


问:
Google Drive API does not work when trying to query files in My Drive, no exception thrown, just empty list while my drives actually contains files
Was trying to use Google Drive API (Java) in my android project. I logged in successfully, and was able to use the list() method successfully, but the getFiles() method return a empty List whereas my google drive actually having more than 100 files. I couldn't find any answer regarding this.</p>