问:
Compatibility With The Mobile Version Of Google Chrome
I'm a beginner in HTML, CSS, and Javascript and am currently in the process of getting a website that I built online. I'm testing it in all browsers to make sure that it works without any issues, but am noticing some issues when on a mobile browser. Specifically, I'm noticing that my website freezes and becomes unusable after viewing a few pages when trying to use it in the mobile version of Google Chrome.

Below is the code that I'm using and if I'm not mistaken I'm sure that there is a line of code inside my CSS that is making Google Chrome freeze on a mobile device. Can anyone see any line of code that should be taken out or replaced? Are there too many scripts for Google Chrome to handle on a mobile device? If anyone has any knowledge about what could possibly be causing this issue I'd really appreciate you sharing it with me.

```<code><!DOCTYPE html>
<html lang="ja">

<head>

<meta name="viewport" content="width=device-width, initial-scale=1.0;" charset="utf-8">

<title>MORIKOBOSHI・</title>

</head>

<body>

<div class="page-wrap">

<div class="cp_cont">
<input id="cp_toggle03" type="checkbox"/>
<div class="cp_mobilebar">
<label for="cp_toggle03" class="cp_menuicon">
<span></span>
</label>
</div>
<label id="h-menu_black" class="cp_toggle03" for="cp_menuicon"></label>
<div id="body" class="noscroll"></div>

<header class="cp_offcm03">

<nav>
<ul style="text-align: center; margin-left: 210px; overflow: hidden; padding-bottom: 10px;">

<li style="border-bottom: .05px solid lightgray;"><a href="#">ホーム</a></li>
<li style="border-bottom: .05px solid lightgray;"><a href="#">ブログ</a></li>
<li style="border-bottom: .05px solid lightgray;"><a href="#">このサイトについて</a></li>
<li style="border-bottom: .05px solid lightgray;"><a href="#">参考文献</a></li>

<div class="searchbar">

<form id="frmSearch" class="search2" method="get" action="default.html" style=" padding-right: 10px; padding-top: 20px; text-align: center; position: inline;">
<input class="search2" id="txtSearch" type="text" placeholder="Googleカスタム検索" name="serach_bar" size="31" maxlength="255" value="" style="top: 185px; width: 180px; height: 26px;">
<input class="search1" type="submit" name="submition" value="検索" style="padding-left: 5px; top: 153px; height: 25px; width: 34px; display: inline-flex; justify-content: center;">
<input class="search2" type="hidden" name="sitesearch" value="default.html">
</form>
</div>

<script type="text/javascript">
 document.getElementById('frmSearch').onsubmit = function() {
 window.location = 'http://www.google.com/search?q=site:morikoboshi.com' + document.getElementById('txtSearch').value;
        return false;
    }

</script>

<script>
 document.getElementById('cp_toggle03').onchange = function() {
 if (document.getElementById('cp_toggle03').checked) {
 document.body.style.overflow = "hidden";
  } else {
 document.body.style.overflow = "";
  }
}

</script>

</ul>
</nav>
</header>

<div class="setsumei">
<br><h1 style="text-align: center; font-size: 40px;">◯◯◯◯</h1>
<br><p style="text-align: justify; font-size: 16px;"></p>

 <p style="text-align: center; font-size: 13px;">著者：◯◯◯◯</p>
 <p style="text-align: center; font-size: 13px;">撮影日：◯◯◯◯年◯◯月◯◯日</p>

 <br><br><p style="text-align: justify; font-size: 16px;">

    #
 </p>

</div>

<br><br><div class="image">

 <a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

 <br><br><a href="#"><img src="#" alt="#" width="90%"></a>

</div>
</div>

<br><br><footer class="site-footer" style="font-size: 12px;">MORIKOBOSHI© | <a href="#">English</a></footer>

</div>

<style>

html {visibility: visible;
      opacity: 1;}

.body{background-color: white;
      font-family: sans-serif;}

 .searchbar{float: right;}

 .image{text-align: center;}

 .setsumei{margin-left: 20px;
           margin-right: 20px;}

 .footer{width: 100%;
           height: 40px;
           text-align: center;
           border-top: 1px solid black;
           position: absolute;
           bottom: 0;
           padding: 10px;}

 .page-wrap {
  min-height: 100%;
  /* equal to footer height */
  margin-bottom: -40px;
}

 .page-wrap:after {
  content: "";
  display: block;
  }

 .site-footer, .page-wrap:after {
  /* .push must be the same height as footer */
  height: 20px;
}

 .site-footer {
  text-align: center;
  border-top: 1px solid black;
  padding: 10px;
}

 *, *:before, *:after {
    padding-left: 0;
    margin: 0;
    box-sizing: border-box;

}

 ol, ul {
    list-style: none;
}

 a {
    text-decoration: none;
    color: black;
}

 .cp_cont {
    height: auto;
}

/* menu */
 .cp_offcm03 {
    position: relative;
    z-index: 5000;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: auto;
    width: 100%;
    height: auto;
    padding-top: 0;
    -webkit-transition: transform 0.3s ease-in;
            transition: transform 0.3s ease-in;
    text-align: center;
    color: black;
    background-color: white;
}
 .cp_offcm03 nav,
 .cp_offcm03 ul {
    height: 100%;
}

 .cp_offcm03 li {
    display: inline-block;
    margin-right: -6px;
}

 .cp_offcm03 a {
    display: block;
    padding: 15px 45px;
    margin-bottom: -5px;
    -webkit-transition: background-color .3s ease-in;
            transition: background-color .3s ease-in;
}

 .cp_offcm03 a:hover {
    background-color: lightgray;
}

/* menu toggle */
 #cp_toggle03 {
    display: none;
}

 #cp_toggle03:checked ~ .cp_offcm03 {
    -webkit-transform: translateX(0);
                    transform: translateX(0);
}

 #cp_toggle03:checked ~ .cp_container {
    -webkit-transform: translateX(0);
                    transform: translateX(0);
}

 .cp_mobilebar {
    display: none;

}

/* content */
 .cp_container {
    position: relative;
    top: 0;
    padding: 35px auto;
    -webkit-transition: transform .3s ease-in;
            transition: transform .3s ease-in;
}

 .cp_content {
    margin: 0 auto;
    padding: 20px;
    height: 65vh;
    text-align: center;

}

@media (max-width: 1130px)and (min-width: 280px) {
/* menu */
 .cp_offcm03 {
        position: fixed;
        left: -250px;
        overflow-y: hidden;
        width: 250px;
        height: 100%;
        padding-top: 40px;
        color: black;
        background-color: white;
        z-index: 1000;
    }

 .cp_offcm03 nav {
        background: white;
        border-right: 0.5px solid lightgray;
        margin-left: -210px;
    }

 .cp_offcm03 li {
        display: block;
        margin-right: 0;}

 .cp_offcm03 a {
        padding: 20px;

    }

/* menu toggle */
 .cp_mobilebar {
        display: block;
        z-index: 2000;
        position: relative;
        top: 0;
        left: 0;
        padding: 0 25px;
        width: 100%;
        height: 40px;
        background-color: white;
        border-bottom: .05px solid lightgray;

    }

 .cp_menuicon {
        display: block;
        position: relative;
        width: 25px;
        height: 100%;
        cursor: pointer;
        -webkit-transition: transform .3s ease-in;
                transition: transform .3s ease-in;
    }
 .cp_menuicon > span {
        display: block;
        position: absolute;
        top: 55%;
        margin-top: -0.3em;
        width: 100%;
        height: 0.2em;
        border-radius: 1px;
        background-color: black;
        -webkit-transition: transform .3s ease;
                transition: transform .3s ease;
    }
 .cp_menuicon > span:before,
 .cp_menuicon > span:after {
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        border-radius: 1px;
        background-color: black;
        -webkit-transition: transform .3s ease-in;
                transition: transform .3s ease-in;
    }

 .cp_menuicon > span:before {
        -webkit-transform: translateY(-0.6em);
                transform: translateY(-0.6em);
    }

 .cp_menuicon > span:after {
        -webkit-transform: translateY(0.6em);
                transform: translateY(0.6em);
    }

 #cp_toggle03:checked + .cp_mobilebar .cp_menuicon {
        -webkit-transform: rotate(45deg);
                transform: rotate(45deg);
    }

 #cp_toggle03:checked + .cp_mobilebar span:before,
 #cp_toggle03:checked + .cp_mobilebar span:after {
        -webkit-transform: rotate(90deg);
                transform: rotate(90deg);
    }

 #cp_toggle03:checked ~ .cp_offcm03 {
        -webkit-transform: translateX(100%);
                transform: translateX(100%);
    }

 #cp_toggle03:checked ~ .cp_container {
        -webkit-transform: translateX(250px);
                transform: translateX(250px);
    }

 input:checked ~ #h-menu_black {
    display: block;/*カバーを表示*/
    opacity: .6;
}

 #h-menu_black {
    display: none;
    position: fixed;
    z-index: 999;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    opacity: 0;
    transition: .7s ease-in-out;
}

/* content */
 .cp_container {
        top: 60px;
        height: 92vh;
        text-align: center;
    }

 .noscroll{
        overflow: hidden;
        position: fixed;
    }

</style>

</body>
</html>
</code>```

Body:
I'm a beginner in HTML, CSS, and Javascript and am currently in the process of getting a website that I built online. I'm testing it in all browsers to make sure that it works without any issues, but am noticing some issues when on a mobile browser. Specifically, I'm noticing that my website freezes and becomes unusable after viewing a few pages when trying to use it in the mobile version of Google Chrome.

Below is the code that I'm using and if I'm not mistaken I'm sure that there is a line of code inside my CSS that is making Google Chrome freeze on a mobile device. Can anyone see any line of code that should be taken out or replaced? Are there too many scripts for Google Chrome to handle on a mobile device? If anyone has any knowledge about what could possibly be causing this issue I'd really appreciate you sharing it with me.

<!DOCTYPE html>

<meta name="viewport" content="width=device-width, initial-scale=1.0;" charset="utf-8">

<title>MORIKOBOSHI・</title>

<input id="cp_toggle03" type="checkbox"/>

ホーム

ブログ

このサイトについて

参考文献

<form id="frmSearch" class="search2" method="get" action="default.html" style=" padding-right: 10px; padding-top: 20px; text-align: center; position: inline;">
<input class="search2" id="txtSearch" type="text" placeholder="Googleカスタム検索" name="serach_bar" size="31" maxlength="255" value="" style="top: 185px; width: 180px; height: 26px;">
<input class="search1" type="submit" name="submition" value="検索" style="padding-left: 5px; top: 153px; height: 25px; width: 34px; display: inline-flex; justify-content: center;">
<input class="search2" type="hidden" name="sitesearch" value="default.html">
</form>

◯◯◯◯

著者：◯◯◯◯

撮影日：◯◯◯◯年◯◯月◯◯日

    #

MORIKOBOSHI© | English


来源: stackexchange

问:
How to insert values into database SQL
Table studentdata:

ID
Name
Class

1001
Paul
1st

Table HolidayList:

Date
Holiday_Name
Status

11-12-2022
Sunday
H

Output:

ID
Name
Class
Date
Intime
Outtime
INAM
OUTPM

1001
Paul
1st
09-12-2022
Holiday
Holiday
H
H

Code:

```<code>SELECT
    studentdata.ID, studentdata.Name, studentdata.Class,
    HolidayList.Date AS Date, HolidayList.Holiday_Name AS Intime,
    Holiday_Name AS Outtime, HolidayList.Status AS INAM,
    HolidayList.Status AS OUTPM
FROM
    studentdata
CROSS JOIN
    HolidayList
</code>```

From this code, I'm getting the output shown, but how can I insert these values into table1 in my database? Thank you...

ContentLicense: CC BY-SA 4.0

Title: How to insert values into database SQL

Body:
Table studentdata:

ID
Name
Class

1001
Paul
1st

Table HolidayList:

Date
Holiday_Name
Status

11-12-2022
Sunday
H

Output:

ID
Name
Class
Date
Intime
Outtime
INAM
OUTPM

1001
Paul
1st
09-12-2022
Holiday
Holiday
H
H

Code:

SELECT
    studentdata.ID, studentdata.Name, studentdata.Class,
    HolidayList.Date AS Date, HolidayList.Holiday_Name AS Intime,
    Holiday_Name AS Outtime, HolidayList.Status AS INAM,
    HolidayList.Status AS OUTPM
FROM
    studentdata
CROSS JOIN
    HolidayList

From this code, I'm getting the output shown, but how can I insert these values into table1 in my database? Thank you...


问:
Laravel query use parent column inside whereRelation
I have problem with my eloquent query, i need to use data of my base model into whereRelation.

I tried this query bottom, but results was not what i except. The query return me all users who have one city relation, not only user who have city updated between my last user sync.

```<code>$users = People::whereRaw('TIMESTAMPDIFF(SECOND, people.latest_sync, people.updated_at) > 20')
    ->orWhereRelation('city', 'updated_at', '>', 'people.updated_at')
    ->get();
</code>```

I'v tried people.updated_at and latest_sync in value of my Where Relation

Do i need to make pure SQL Raw query with classic join ?

PS: the first whereRaw is ok, and work (i really need)

Body:
I have problem with my eloquent query, i need to use data of my base model into whereRelation.

I tried this query bottom, but results was not what i except. The query return me all users who have one city relation, not only user who have city updated between my last user sync.

$users = People::whereRaw('TIMESTAMPDIFF(SECOND, people.latest_sync, people.updated_at) > 20')
    ->orWhereRelation('city', 'updated_at', '>', 'people.updated_at')
    ->get();

I'v tried people.updated_at and latest_sync in value of my Where Relation

Do i need to make pure SQL Raw query with classic join ?

PS: the first whereRaw is ok, and work (i really need)


问:
Skype in business: Delete the contact in new tab from the other side after add contact\sending notification
I have added someone on the contact list incorrectly on Skype Business Office, now I want to erase the notification effect that goes for him and puts me on his new list. His removal from my contact is no use.how to remove my contate in remote\other side   "new tab" Skype Business ?</p>


问:
MongoDB concatenate for dictionary key
I am trying to update a dictionary field in MongoDB. But I can't figure out a way to update nested dictionary with a variable as key.

Here is the schema

```<code>const UserSchema = new mongoose.Schema({
    email: String,
    password: {type: String, unique: true, required: true},
    id: mongoose.Schema.Types.ObjectId,
    course: mongoose.Schema.Types.Mixed
});
</code>```

I am trying to update course so that every time a course name is added as a key in the following form, with course name stored in the variable addName

For example, if addName = Intro to Computer Science, the desired result would be

```<code>{
  "email" 12345@gmail.com,
  ...
  "course": {
     "Intro to Computer Science" {
        "syllabus": ""
      }

  }

}
</code>```

However, I am not sure how to add a variable key to the dictionary. When I tried below, but I get the following syntax error

```<code>app.post("/api/add-course/", (req, res) => {
  const email = req.body.email;
  const addName = req.body.addName;
  console.log(req.body)// assumes that User was registered in `./db.mjs`
  User.updateOne({"email": email}, {'$set': {'course.'+addName: {"syllabus": ""}}},
    ).then(result => {
    res.status(201).json({
        message: "success",
        course: user.course
    })
  }).catch(err => {
    console.log(err),
        res.status(500).json({
            error: err
        });
  });
  console.log(user);
})
</code>```

Title: MongoDB concatenate for dictionary key

Body:
I am trying to update a dictionary field in MongoDB. But I can't figure out a way to update nested dictionary with a variable as key.

Here is the schema

const UserSchema = new mongoose.Schema({
    email: String,
    password: {type: String, unique: true, required: true},
    id: mongoose.Schema.Types.ObjectId,
    course: mongoose.Schema.Types.Mixed
});

I am trying to update course so that every time a course name is added as a key in the following form, with course name stored in the variable addName

For example, if addName = Intro to Computer Science, the desired result would be

{
  "email" 12345@gmail.com,
  ...
  "course": {
     "Intro to Computer Science" {
        "syllabus": ""
      }

  }

}

However, I am not sure how to add a variable key to the dictionary. When I tried below, but I get the following syntax error

app.post("/api/add-course/", (req, res) => {
  const email = req.body.email;
  const addName = req.body.addName;
  console.log(req.body)// assumes that User was registered in `./db.mjs`
  User.updateOne({"email": email}, {'$set': {'course.'+addName: {"syllabus": ""}}},
    ).then(result => {
    res.status(201).json({
        message: "success",
        course: user.course
    })
  }).catch(err => {
    console.log(err),
        res.status(500).json({
            error: err
        });
  });
  console.log(user);
})


问:
How to take only payment on another woocomerce website
I want to redirect my buyers to my second website 'B' to make payment for my product on website 'A' and after successful payment on website 'B', it should automatically update the order status on website 'A' as the order is completed. I am using woo commerce plugin for my websites. Please any plugins, Add-ons, or custom code suggestions. please I need help

Site 'A'

```<code>function action_woocommerce_new_order( $order_id ) {

    //get all order details by $order_id
    //post your data to site B

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL,"http://yoursiteB.com/wp-json/api/v2/create_wc_order");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,
            "postvar1=value1&postvar2=value2");

    // In real life you should use something like:
    // curl_setopt($ch, CURLOPT_POSTFIELDS,
    //          http_build_query(array('postvar1' => 'value1')));

    // Receive server response ...
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $server_output = curl_exec($ch);

    curl_close ($ch);
};
add_action( 'woocommerce_payment_complete', 'action_woocommerce_new_order', 10, 1 );
</code>```

Site 'B'

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

Class WC_Rest_API {

```<code>public function __construct() {
    add_action( 'rest_api_init', array( $this, 'init_rest_api') );
}

public function init_rest_api() {
    register_rest_route('api/v2', '/create_wc_order', array(
       'methods' => 'POST',
       'callback' => array($this,'create_wc_order'),
    ));
</code>```

}

```<code>public function create_wc_order( $data ) {

        //$data  - all the details needs to be send from site A

        global $woocommerce;
        $user_id = $data['user_id'];
        $user = get_user_by( 'ID', $user_id);
        $phonenumer = get_user_meta( $user_id,'user_phoneno', true);

        if($user) {

            $address = array(
              'first_name' => $user->display_name,
              'last_name'  => $user->display_name,
              'email'      => $user->user_email,
              'phone'      => $phonenumer,
            );

            $order = wc_create_order();
            //get product details from rest api site A
            $order->add_product();
            $order->set_address( $address, 'billing' );

            $order->calculate_totals();
            $order = wc_get_order( $order->id );

            $response['status'] = 'success';
            $response['message'] = 'Order created on wordpress site B.';
            return new WP_REST_Response($response, 200);

      }

}
</code>```

}

$rest_api = new WC_Rest_API();

```<code>this doesn't work as it create product on the second website.
I want to use the second website to make only payment if it can pull user data and order id only
</code>```

Body:
I want to redirect my buyers to my second website 'B' to make payment for my product on website 'A' and after successful payment on website 'B', it should automatically update the order status on website 'A' as the order is completed. I am using woo commerce plugin for my websites. Please any plugins, Add-ons, or custom code suggestions. please I need help

Site 'A'

function action_woocommerce_new_order( $order_id ) {

    //get all order details by $order_id
    //post your data to site B

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL,"http://yoursiteB.com/wp-json/api/v2/create_wc_order");
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS,
            "postvar1=value1&postvar2=value2");

    // In real life you should use something like:
    // curl_setopt($ch, CURLOPT_POSTFIELDS,
    //          http_build_query(array('postvar1' => 'value1')));

    // Receive server response ...
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $server_output = curl_exec($ch);

    curl_close ($ch);
};
add_action( 'woocommerce_payment_complete', 'action_woocommerce_new_order', 10, 1 );

Site 'B'

Class WC_Rest_API {

public function __construct() {
    add_action( 'rest_api_init', array( $this, 'init_rest_api') );
}

public function init_rest_api() {
    register_rest_route('api/v2', '/create_wc_order', array(
       'methods' => 'POST',
       'callback' => array($this,'create_wc_order'),
    ));

}

public function create_wc_order( $data ) {

        //$data  - all the details needs to be send from site A

        global $woocommerce;
        $user_id = $data['user_id'];
        $user = get_user_by( 'ID', $user_id);
        $phonenumer = get_user_meta( $user_id,'user_phoneno', true);

        if($user) {

            $address = array(
              'first_name' => $user->display_name,
              'last_name'  => $user->display_name,
              'email'      => $user->user_email,
              'phone'      => $phonenumer,
            );

            $order = wc_create_order();
            //get product details from rest api site A
            $order->add_product();
            $order->set_address( $address, 'billing' );

            $order->calculate_totals();
            $order = wc_get_order( $order->id );

            $response['status'] = 'success';
            $response['message'] = 'Order created on wordpress site B.';
            return new WP_REST_Response($response, 200);

      }

}

}

$rest_api = new WC_Rest_API();

this doesn't work as it create product on the second website.
I want to use the second website to make only payment if it can pull user data and order id only


问:
nmcli create Hotspot with HT parametrs
i have created a Hotspot with nmcli command. But the Hotspot have very low bandwidth. After debugging found out that the HT parameters isn't set.
Would like to know how to set the HT parameters using nmcli command.
eg: HT20 and HT40 parameters set in hostapd</p>

Title: nmcli create Hotspot with HT parametrs


问:
Error: Cannot find module './src/handlers/buttons.js' after migrating all files to a ./src folder
I'm working on a Discord bot using the popular Discord.js library

I've recently moved all my non config files to a folder called 'src'

In my 'index.js' file I have an fs statement that reads all the files in a directory called './src/handlers'
Here is that code:

```<code>fs.readdirSync(`./src/handlers`).forEach((handler) => {
  require(`./src/handlers/${handler}`)(client)
});

</code>```

Yes, I've imported the 'fs' module.
Here's my button.js code incase it has something to do with the error
(there are more files in the handlers folder, so it's not likely that button.js is giving me the error, it's probably that it's the one at the top of the list)

```<code>const fs = require('fs');
const chalk = require('chalk')
var AsciiTable = require('ascii-table')
var table = new AsciiTable()
table.setHeading('Buttons', 'Stats').setBorder('|', '=', "0", "0")

module.exports = (client) => {
    fs.readdirSync('./src/buttons/').filter((file) => file.endsWith('.js')).forEach((file) => {
        const button = require(`../buttons/${file}`)
        client.buttons.set(button.id, button)
        table.addRow(button.id, '✅')
    })
        console.log(chalk.cyanBright(table.toString()))
};

</code>```

Body:
I'm working on a Discord bot using the popular Discord.js library

I've recently moved all my non config files to a folder called 'src'

In my 'index.js' file I have an fs statement that reads all the files in a directory called './src/handlers'
Here is that code:

fs.readdirSync(`./src/handlers`).forEach((handler) => {
  require(`./src/handlers/${handler}`)(client)
});

Yes, I've imported the 'fs' module.
Here's my button.js code incase it has something to do with the error
(there are more files in the handlers folder, so it's not likely that button.js is giving me the error, it's probably that it's the one at the top of the list)

const fs = require('fs');
const chalk = require('chalk')
var AsciiTable = require('ascii-table')
var table = new AsciiTable()
table.setHeading('Buttons', 'Stats').setBorder('|', '=', "0", "0")

module.exports = (client) => {
    fs.readdirSync('./src/buttons/').filter((file) => file.endsWith('.js')).forEach((file) => {
        const button = require(`../buttons/${file}`)
        client.buttons.set(button.id, button)
        table.addRow(button.id, '✅')
    })
        console.log(chalk.cyanBright(table.toString()))
};


问:
Why is my keyframes animation only working one way?
I have a CSS keyframes animation that I'm using like so:

.content[docked=true] {
    animation: dockContent ease var(--dock-animation-time);
    animation-direction: normal;
    animation-fill-mode: forwards;
}
.content[docked=false] {
    animation: dockContent ease var(--dock-animation-time);
    animation-direction: reverse;
    animation-fill-mode: backwards;
}
```

When the docked attribute is set to true, it animates as expected. Afterwards, when the docked attribute is set to false, it doesn't animate and instead snaps to the initial values (0% -- it's running in backwards) as if there were no animation at all. The animation is still being run through though, because I am not setting the CSS rules back to their starting values anywhere except for the animation. After reverting the docked attribute to false, setting it to true again results in the same 'jump' with the expected end values but no transition or value interpolation. Why is this happening?

My animation is too elaborate to use transitions because it sets values in non-linear ways along its duration. That's exactly why I'd prefer not to have to make a second animation with all the values flipped.

Body:
I have a CSS keyframes animation that I'm using like so:

.content[docked=true] {
    animation: dockContent ease var(--dock-animation-time);
    animation-direction: normal;
    animation-fill-mode: forwards;
}
.content[docked=false] {
    animation: dockContent ease var(--dock-animation-time);
    animation-direction: reverse;
    animation-fill-mode: backwards;
}

When the docked attribute is set to true, it animates as expected. Afterwards, when the docked attribute is set to false, it doesn't animate and instead snaps to the initial values (0% -- it's running in backwards) as if there were no animation at all. The animation is still being run through though, because I am not setting the CSS rules back to their starting values anywhere except for the animation. After reverting the docked attribute to false, setting it to true again results in the same 'jump' with the expected end values but no transition or value interpolation. Why is this happening?

My animation is too elaborate to use transitions because it sets values in non-linear ways along its duration. That's exactly why I'd prefer not to have to make a second animation with all the values flipped.


问:
Azure IOT Hub , Device Twin vs Device to Cloud messages , can both be used together?
We have use case where Device Twin to be used for executing commands (by changing desired properties). Also , there is telemetry data flow and we are planning to use device to cloud message. The question stands

Can both (twin and messaging) be used , if so how to manage updating reported properties of device twin ? Understand updating it for every device to cloud message will affect performance

If device twin alone can be used for managing telemetry message and commands.  What will be the performance consideration for reading device twin reported properties on right side of Iot Hub

The frequnecy of telemetry messages will be every hour and total device will be around 50k

We tried device to cloud and cloud to device messages , but as per customer needs Device Twin for futuristic Devices which can directly read and update Device Twin


问:
Read Data MODBUS over UDP/IP using Python
I am trying to use Python to read a modbus device. I used ModeBuse poll software to read the data from device. The software settings are as follows

I am trying to use Python to read a modbus device. I used ModeBuse poll software to read the data from the device. The software settings are as follows. Is this possible with the minimalmodebus library?


问:
Facebook Share Dialog isn't working from mobile
I'm using the Facebook Share Dialog by using URL Redirection, followed this documentation:
https://developers.facebook.com/docs/sharing/reference/share-dialog/#:~:text=for%20Webmasters.-,Share%20by%20Using%20URL%20Redirection,-To%20share%20a

When submitting a private message via mobile, the next error arises: "Attachment Not Found: The attachment could not be found". It only happens in mobile. When I try it from desktop everything works fine.

I tried contact Facebook support but their support channel in no longer available for this feature.
Any idea?

Thanks!


问:
3-Card Monty Game With Counting Wins/Losses
I'm trying to create a looping 3-card Monty game where the user inputs a "cup" choice and if they win or lose, there is a counter that tallies up the wins and losses. I've written the code below but it doens't keep the current tally. It just resets to 1 win or 1 loss after every game. What am I doing wrong? I'm just getting into functions as a newbie. Thanks!</p>
```<code>from random import shuffle

def shuffle_list(mylist):
    shuffle(mylist)
    return mylist

def player_guess():
    guess = ''
    while guess not in ['0', '1' ,'2']:
        guess = input('Pick A Number: 0, 1, 2\n')
    return int(guess)

correctguess = 0
incorrectguess = 0

def check_guess (mylist,guess,correctguess,incorrectguess):
    if mylist[guess] == 'O':
        correctguess =+ 1
        print (f'Yes! Correct: {correctguess} Incorrect: {incorrectguess}')

    else:
        incorrectguess += 1
        print (f'No! Ccorrect: {correctguess} Incorrect: {incorrectguess}')
        print (mylist)

while True:
    mylist = [' ', 'O', ' ']
    mixesup_list = shuffle_list(mylist)
    guess = player_guess()
    check_guess(mixesup_list,guess)
</code>```

Body:
I'm trying to create a looping 3-card Monty game where the user inputs a "cup" choice and if they win or lose, there is a counter that tallies up the wins and losses. I've written the code below but it doens't keep the current tally. It just resets to 1 win or 1 loss after every game. What am I doing wrong? I'm just getting into functions as a newbie. Thanks!

from random import shuffle

def shuffle_list(mylist):
    shuffle(mylist)
    return mylist

def player_guess():
    guess = ''
    while guess not in ['0', '1' ,'2']:
        guess = input('Pick A Number: 0, 1, 2\n')
    return int(guess)

correctguess = 0
incorrectguess = 0

def check_guess (mylist,guess,correctguess,incorrectguess):
    if mylist[guess] == 'O':
        correctguess =+ 1
        print (f'Yes! Correct: {correctguess} Incorrect: {incorrectguess}')

    else:
        incorrectguess += 1
        print (f'No! Ccorrect: {correctguess} Incorrect: {incorrectguess}')
        print (mylist)

while True:
    mylist = [' ', 'O', ' ']
    mixesup_list = shuffle_list(mylist)
    guess = player_guess()
    check_guess(mixesup_list,guess)


问:
I used the ddpkg-buildpackage tool to generate the deb package in linux, and the dynamic library of the dependent report could not be found
My project is based on QT5.14 and relies on the mxml library and libhv library. Now to port to Ubuntu, I choose to use ddpkg-buildpackage to generate the deb package. Run the dpkg-buildpackage -b -rfakeroot -us-uc command. The following error message is displayed:

dpkg-shlibdeps: error: cannot find library libmxml.so.1 need by debian/pip/opt/pip/bin/pip(ELF format:  elf64-littleaarch64 abi:'020100b7000000000';  rpath:'usr/lib/qt5/lib')

How can I solve this problem?
I am not familiar with linux environment, please help me to look at it, thank you

This is the structure directory for my project

pip

pip/src             // source code
pip/vendor          // dependent library directory
pip/vendor/mxml/lib/libmxml.so.1
pip/vendor/libhv/lib/libhv.so

debian/ruler Is generated using dh_make and is not modified

I am not familiar with linux environment


问:
how to call a JS function From Python tkinter button click
Is it possible to Call a script from Tkinter.

OR Is it possible to import JS files in a Python Project and Excecute the JS Function inside
Python function

thanks in advance.


问:
Download TikTok mp4 on client-side in Django App
I am working on an app and want to download a TikTok video given a URL on the client's machine. I have tried the following to no avail. I would like to do this in as lightweight a manner as possible and with libraries that are popular and maintained, if possible. The issues I have gotten for the attempts are provided therein.

Using https://github.com/davidteather/TikTok-Api

While this works locally, it does not work when I deploy the application, as I get issues with the threading. I copied over the code from this library and messed around with the threading, but it still did not work fully. I would like to avoid this option as it is not super maintainable.

Using requests/wget

I get the following issue when trying to use wget: Error downloading video: 'ascii' codec can't decode byte 0xe2 in position 248: ordinal not in range(128) [11/Dec/2022 05:10:13] "GET /downloader/https://www.tiktok.com/@patrickzeinali/video/7143758925349784874?is_copy_url=1&is_from_webapp=v1&item_id=7143758925349784874&lang=en HTTP/1.1" 200 24

This is what the current files look like:
downloader/urls.py

```<code>from django.urls import re_path, path
from . import views

urlpatterns = [
    path('<path:video_url>', views.download_video, name='download_video'),
]`
</code>```

downloader/views.py

```<code>from django.http import HttpResponse
import ENV_VARS
import requests
import wget

def download_video(request, video_url):
    print(f'Received request for video at URL: {video_url}')
    # Use the `requests` library to fetch the TikTok video from the specified URL
    try:
        response = requests.get(video_url, headers=ENV_VARS.HEADERS)
    except Exception as e:
        print(f'Error fetching video from URL: {e}')
        return HttpResponse('Error fetching video from URL!')
    # Use the `wget` library to download the TikTok video to the client's device
    print(f'Received response from video URL: {response.text}')
    try:
        wget.download(response.content)
    except Exception as e:
        print(f'Error downloading video: {e}')
        return HttpResponse('Error downloading video!')
    # Return a success message to the client
    return HttpResponse('TikTok video downloaded successfully!')
</code>```

Any and all information would be super helpful. Thanks!

Body:
I am working on an app and want to download a TikTok video given a URL on the client's machine. I have tried the following to no avail. I would like to do this in as lightweight a manner as possible and with libraries that are popular and maintained, if possible. The issues I have gotten for the attempts are provided therein.

Using https://github.com/davidteather/TikTok-Api

While this works locally, it does not work when I deploy the application, as I get issues with the threading. I copied over the code from this library and messed around with the threading, but it still did not work fully. I would like to avoid this option as it is not super maintainable.

Using requests/wget

I get the following issue when trying to use wget: Error downloading video: 'ascii' codec can't decode byte 0xe2 in position 248: ordinal not in range(128) [11/Dec/2022 05:10:13] "GET /downloader/https://www.tiktok.com/@patrickzeinali/video/7143758925349784874?is_copy_url=1&is_from_webapp=v1&item_id=7143758925349784874&lang=en HTTP/1.1" 200 24

This is what the current files look like:
downloader/urls.py

from django.urls import re_path, path
from . import views

urlpatterns = [
    path('<path:video_url>', views.download_video, name='download_video'),
]`

downloader/views.py

from django.http import HttpResponse
import ENV_VARS
import requests
import wget

def download_video(request, video_url):
    print(f'Received request for video at URL: {video_url}')
    # Use the `requests` library to fetch the TikTok video from the specified URL
    try:
        response = requests.get(video_url, headers=ENV_VARS.HEADERS)
    except Exception as e:
        print(f'Error fetching video from URL: {e}')
        return HttpResponse('Error fetching video from URL!')
    # Use the `wget` library to download the TikTok video to the client's device
    print(f'Received response from video URL: {response.text}')
    try:
        wget.download(response.content)
    except Exception as e:
        print(f'Error downloading video: {e}')
        return HttpResponse('Error downloading video!')
    # Return a success message to the client
    return HttpResponse('TikTok video downloaded successfully!')

Any and all information would be super helpful. Thanks!


问:
Trigger Multiple queries in a single button mysql (javaScript)
I've already searched that inserting information in multiple tables in the same query is impossible.
But is it possible to trigger the multiple queries by a single button?

For example I create a
function firstTable($name, $email){ INSERT INTO 'students' ('name', 'email') VALUES ('$name', '$email') }
and another function with a similar query but this time storing it into a different table
function secondTable($name, $email){ INSERT INTO 'backupTable' ('name', 'email') VALUES ('$name', '$email') }

I originally wanted to create a backup table but the process that I'm thinking is whenever a student register, it will simultaneously store into two tables and for a certain time, I could delete the data on the first table but I still have a backup for it. But I researched that it is impossible for it to simultaneously store that's why I come up with that idea. Please be kind to me when answering especially if my question is laughable, I am just a student. If there are better ways in my approach please enlighten me as I have a limited knowledge in php and mysql


问:
Generate DWARF debug info in wasm binary from go?
I'm trying to generate a wasm binary with DWARF debugging info via (non-Tiny) Go. Despite many iterations with the build, gimli/dwarfdump keeps showing empty debug data sections (though it shows non-empty debug data when pointed at a native linux Go executable).

I don't know whether there's a tool bug or I'm just doing this wrong, would appreciate your comments.

Run the build this way:

GOOS=js GOARCH=wasm go build -a -work -x -gcflags="-N -dwarf=true -dwarflocationlists=false" -ldflags="-w=false" -o mmm . >build2.log 2>&1
```
<p>(A lot of experimentation showed I had to specify these <code>-cflags</code> and <code>-ldflags</code> to override hardcoded defaults build was feeding the compile and link tools...)</p>
<p>Observe log file seems to invoke the tools with the right options:</p>
<pre class="lang-bash prettyprint-override"><code>--- snip ---
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/b001/_pkg_.a -trimpath "$WORK/b001=>" -p main -lang=go1.14 -complete -buildid wrV2MKYl_2wAOfC9V6TW/wrV2MKYl_2wAOfC9V6TW
 -dwarf=false -goversion go1.19.4 -N -dwarf=true -dwarflocationlists=false -nolocalimports -importcfg $WORK/b001/importcfg -pack ./0_components_vgen.go ./generate.go ./main_wasm.go
--- snip ---
/usr/local/go/pkg/tool/linux_amd64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/importcfg.link -buildmode=exe -buildid=NCMJg-CFGnRWYpYW5of2/wrV2MKYl_2wAOfC9V6TW/KT0X-n_LvOuN7jmi-7Tt/NCMJg-CFGnRWYpYW5of2 -extld=gcc -w=false $WORK/b001/_pkg_.a
/usr/local/go/pkg/tool/linux_amd64/buildid -w $WORK/b001/exe/a.out # internal
cp $WORK/b001/exe/a.out mmm

</code>```

But dwarfdump (always) shows empty debug data sections:

$ dwarfdump mmm

.debug_info

.debug_types

.debug_pubnames

.debug_aranges

.debug_pubtypes
```

Body:
I'm trying to generate a wasm binary with DWARF debugging info via (non-Tiny) Go. Despite many iterations with the build, gimli/dwarfdump keeps showing empty debug data sections (though it shows non-empty debug data when pointed at a native linux Go executable).

I don't know whether there's a tool bug or I'm just doing this wrong, would appreciate your comments.

Run the build this way:

GOOS=js GOARCH=wasm go build -a -work -x -gcflags="-N -dwarf=true -dwarflocationlists=false" -ldflags="-w=false" -o mmm . >build2.log 2>&1

(A lot of experimentation showed I had to specify these -cflags and -ldflags to override hardcoded defaults build was feeding the compile and link tools...)

Observe log file seems to invoke the tools with the right options:

--- snip ---
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/b001/_pkg_.a -trimpath "$WORK/b001=>" -p main -lang=go1.14 -complete -buildid wrV2MKYl_2wAOfC9V6TW/wrV2MKYl_2wAOfC9V6TW
 -dwarf=false -goversion go1.19.4 -N -dwarf=true -dwarflocationlists=false -nolocalimports -importcfg $WORK/b001/importcfg -pack ./0_components_vgen.go ./generate.go ./main_wasm.go
--- snip ---
/usr/local/go/pkg/tool/linux_amd64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/importcfg.link -buildmode=exe -buildid=NCMJg-CFGnRWYpYW5of2/wrV2MKYl_2wAOfC9V6TW/KT0X-n_LvOuN7jmi-7Tt/NCMJg-CFGnRWYpYW5of2 -extld=gcc -w=false $WORK/b001/_pkg_.a
/usr/local/go/pkg/tool/linux_amd64/buildid -w $WORK/b001/exe/a.out # internal
cp $WORK/b001/exe/a.out mmm

But dwarfdump (always) shows empty debug data sections:

$ dwarfdump mmm

.debug_info

.debug_types

.debug_pubnames

.debug_aranges

.debug_pubtypes


问:
How to make Unity Transport work for non-local server? Are there any better solutions for sending a string of data between devices?
I am writing a program that takes touchscreen input on my Android phone. I then want to send that input to my Windows PC, which will simulate keyboard input. Essentially, the program will allow me to use my phone to control my PC.
The phone displays a joystick and 7 buttons, and the data is to be sent as follows (as a string):
Char 1: 1-9, represents the section of the joystick being tapped, with 1 being bottom left, 5 being centre and 9 being top right.
Chars 2-8: 0 or 1, represents if the corresponding button is currently pressed.

What is the best way to send this data between the mobile device and the computer? Is there a bluetooth/USB-C solution that allows me to directly connect the devices? Or should the data be sent through a server (and if so, what is the easiest networking solution to use?)?

I have tried Unity Transport, but am also unclear on a few details (and I am looking for other solutions, as it does not appear to work).

How do I make the client try to connect to the server device? Which address do I use, and how do I acquire said address?

Can the computer be used as a server without any special hardware?

Will I need to change any settings on either device to make Unity Transport work properly? Will router settings be an issue?

I know that the below code will work with a local server, what do I need to replace "LoopbackIPv4" with to connect to an external server?

```<code>var endpoint = NetworkEndPoint.LoopbackIPv4;
</code>```

Are there any simpler solutions than Unity Transport, or is this the best option?

Body:
I am writing a program that takes touchscreen input on my Android phone. I then want to send that input to my Windows PC, which will simulate keyboard input. Essentially, the program will allow me to use my phone to control my PC.
The phone displays a joystick and 7 buttons, and the data is to be sent as follows (as a string):
Char 1: 1-9, represents the section of the joystick being tapped, with 1 being bottom left, 5 being centre and 9 being top right.
Chars 2-8: 0 or 1, represents if the corresponding button is currently pressed.

What is the best way to send this data between the mobile device and the computer? Is there a bluetooth/USB-C solution that allows me to directly connect the devices? Or should the data be sent through a server (and if so, what is the easiest networking solution to use?)?

I have tried Unity Transport, but am also unclear on a few details (and I am looking for other solutions, as it does not appear to work).

How do I make the client try to connect to the server device? Which address do I use, and how do I acquire said address?

Can the computer be used as a server without any special hardware?

Will I need to change any settings on either device to make Unity Transport work properly? Will router settings be an issue?

I know that the below code will work with a local server, what do I need to replace "LoopbackIPv4" with to connect to an external server?

var endpoint = NetworkEndPoint.LoopbackIPv4;

Are there any simpler solutions than Unity Transport, or is this the best option?


问:
Missing Credentials - Node/Express server Passport.js authentification problem with Sequelize ORM
I'm trying to implement an authentication system using Passport.js for my express web server. However I can't let passport.js do his job in any way , could someone explain me why?

Here is my passport-config.js ;
`

```<code>const LocalStrategy = require('passport-local').Strategy
const bcrypt = require('bcrypt')
const database = require('./modules/database')

function initialize(passport, getUserByUsername) {
  const authenticateUser = async (username, password, done) => {
    const user = await getUserByUsername(username)
    if (user == null) {
      return done(null, false, { message: 'No user with that username' })
    }

    try {
      if (await bcrypt.compare(password, user.password)) {
        return done(null, user)
      } else {
        return done(null, false, { message: 'Password incorrect' })
      }
    } catch (e) {
      return done(e)
    }
  }

  passport.use(new LocalStrategy({ usernameField: 'username' , passwordField: 'password' }, authenticateUser))
  passport.serializeUser((user, done) => done(null, user.username))
  passport.deserializeUser((username, done) => {
    return done(null, getUserByUsername(username))
  })
}

</code>```

Here is how i initialize it within app.js ;

```<code>initializePassport(
    passport ,
    username => database.User.findOne({where : {username : username}}).then(user => {return user || null})
)
</code>```

Here is my get and post /login routers;

```<code>app.get("/login",  function(req, res, next){
    beforeEach(req, res)
    res.render("login.ejs", {
        session: req.session
    })
})

app.post('/login' , passport.authenticate('local', {
    successRedirect : '/main',
    failureRedirect: '/login',
    failureFlash : true
}))
</code>```

I thought I implemented everything properly , maybe passport can't access the username and password? Here is my login.ejs as well;

```<code><!DOCTYPE html>
<head>
    <link rel="stylesheet" href="common.css">
    <link rel="stylesheet" href="log_sign.css">
</head>

<body>
    <%- include("banner.ejs", {}) %>
    <div class="col d-flex justify-content-center">
        <div class="extra-padding">
            <div class="card" style="width: 18rem;">
                <div class="card-body">
                    <h1>Log in</h1>
                    <% if (messages.error) { %>
                        <%= messages.error %>
                      <% } %>
                    <form action="/login" method="POST">
                        <div class="form-group">
                            <label for="username">Username</label>
                            <input for="username" type="username" class="form-control" id="username" placeholder="Enter username">
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="password">Password</label>
                            <input for="password" type="password" class="form-control" id="password" placeholder="Password">
                        </div>
                        <a class="nav-item" href="register">Need an account ? Sign in</a>
                        <div class="col d-flex justify-content-center">
                        <button type="submit" class="btn btn-primary">Submit</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

</body>
</code>```

Body:
I'm trying to implement an authentication system using Passport.js for my express web server. However I can't let passport.js do his job in any way , could someone explain me why?

Here is my passport-config.js ;
`

const LocalStrategy = require('passport-local').Strategy
const bcrypt = require('bcrypt')
const database = require('./modules/database')

function initialize(passport, getUserByUsername) {
  const authenticateUser = async (username, password, done) => {
    const user = await getUserByUsername(username)
    if (user == null) {
      return done(null, false, { message: 'No user with that username' })
    }

    try {
      if (await bcrypt.compare(password, user.password)) {
        return done(null, user)
      } else {
        return done(null, false, { message: 'Password incorrect' })
      }
    } catch (e) {
      return done(e)
    }
  }

  passport.use(new LocalStrategy({ usernameField: 'username' , passwordField: 'password' }, authenticateUser))
  passport.serializeUser((user, done) => done(null, user.username))
  passport.deserializeUser((username, done) => {
    return done(null, getUserByUsername(username))
  })
}

Here is how i initialize it within app.js ;

initializePassport(
    passport ,
    username => database.User.findOne({where : {username : username}}).then(user => {return user || null})
)

Here is my get and post /login routers;

app.get("/login",  function(req, res, next){
    beforeEach(req, res)
    res.render("login.ejs", {
        session: req.session
    })
})

app.post('/login' , passport.authenticate('local', {
    successRedirect : '/main',
    failureRedirect: '/login',
    failureFlash : true
}))

I thought I implemented everything properly , maybe passport can't access the username and password? Here is my login.ejs as well;

<!DOCTYPE html>

    <link rel="stylesheet" href="common.css">
    <link rel="stylesheet" href="log_sign.css">

    <%- include("banner.ejs", {}) %>

Log in

                    <% if (messages.error) { %>
                        <%= messages.error %>
                      <% } %>
                    <form action="/login" method="POST">

                            Username
                            <input for="username" type="username" class="form-control" id="username" placeholder="Enter username">

                            Password
                            <input for="password" type="password" class="form-control" id="password" placeholder="Password">

                        Need an account ? Sign in

                        <button type="submit" class="btn btn-primary">Submit</button>

                    </form>


问:
How to use babel to support tc39 proposal in angular?
I want to use the pipeline-operator in my angular14 project.

What should I do?


问:
Is it possible to keep the SFX progress bar longer until the main window pop up?
I am making a self extract and running installer. It works, but there is a time gap between the exit of the progress bar of the extraction and the appearance of the main window. The process of the executable has already started, it just the GUI hasn't popped up yet.

I guess I can make another loading screen for my program, but since we already have a loading box from 7z I want to make use of it. Is there a way to tell 7z that the finish line is when the window pop up?


问:
Why does my solution to The Cigarette Smoker's Problem not terminate?
I wrote a solution to The Cigarette Smoker's Problem that does not terminate.

A full description of the problem and pseudo-code for the solution can be found here. Briefly, the task is to synchronize four processes using semaphores.

I used the pseudo-code as a guide for writing my solution. The following is my C implementation of the solution:

```<code>#include "sem.h"      //Allows the use of semget(), sem_create(), and the P() and V() functions.
#include <stdlib.h>   //Allows the use of srand() and rand().
#include <time.h>     //Allows the use of time().
#include <stdbool.h>  //Allows the use of the boolean variable that terminates smoker processes
#include <unistd.h>   //Allows the use of fork().
#include <sys/wait.h> //Allows the use of waitpid().

int main()
{

  /*Create and initialize semaphores*/
  int smkr_matches = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT); // Smoker that has matches
  int smkr_tobacco = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT); // Smoker that has tobacco
  int smkr_paper = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT);   // Smoker that has paper
  int agent = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT);
  int lock = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT); // The mutex variable

  /*According to http://www.cs.umd.edu/~hollings/cs412/s96/synch/smokers.html,
    all semaphores are initialized to zero except "lock", which is initialized to one.
  */
  sem_create(smkr_matches, 0);
  sem_create(smkr_tobacco, 0);
  sem_create(smkr_paper, 0);
  sem_create(agent, 0);
  sem_create(lock, 1);

  /*Seed the random number generator to generate random choice of ingredients.*/
  srand(time(NULL));

  // Delcare a boolean variable to terminate the smoker processes.
  bool done = false;

  //Declare variables to store PID after wait() calls and status.
  int pid = 0;
  int status = 0;

  /*Declare variables to store PIDs.*/
  int smkr_mat_PID = 0;
  int smkr_tob_PID = 0;
  int smkr_pap_PID = 0;
  int agent_PID = 0;

  /*Implement the agent process*/
  agent_PID = fork();

  if (agent_PID == -1)
  { // Forking the agent process failed
    perror("Forking the agent process");
    exit(EXIT_FAILURE);
  }

  else if (agent_PID == 0)
  {
    printf("AGENT process created (PID = %d).\n", getpid());
    int rand_num = 0;
    for (int i = 0; i < 4; i++)
    { // Agent will place items on table ten times.
      P(lock);

      // Randomly choose a pair of ingredients.
      rand_num = (rand() % 3) + 1;

      // Place the ingredients on the table and wake the appropriate smoker.
      if (rand_num == 1)
      {
        printf("AGENT has placed TOBACCO and PAPER on the table.\n");
        printf("AGENT wakes smoker with MATCHES.\n");
        V(smkr_matches);
      }
      else if (rand_num == 2)
      {
        printf("AGENT has placed TOBACCO and MATCHES on the table.\n");
        printf("AGENT wakes smoker with PAPER.\n");
        V(smkr_paper);
      }
      else if (rand_num == 3)
      {
        printf("AGENT places MATCHES and PAPER on the table.\n");
        printf("AGENT wakes smoker with TOBACCO.\n");
        V(smkr_tobacco);
      }

      // Allow the smoker to work
      V(lock);

      printf("AGENT will now sleep.\n");
      P(agent);
    }

    done = true;
  }

  /*Implement the smoker with tobacco*/
  else
  {
    smkr_tob_PID = fork();

    if (smkr_tob_PID == -1)
    {
      perror("Forking smoker with tobacco");
      exit(EXIT_FAILURE);
    }

    else if (smkr_tob_PID == 0)
    {
      printf("SMOKER WITH TOBACCO created. (PID = %d)\n", getpid());
      while(done == false)
      {
        P(smkr_tobacco);
        P(lock);
        printf("SMOKER WITH TOBACCO picks up matches and paper from the table.\n");
        V(agent);
        V(lock);
        printf("SMOKER WITH TOBACCO begins smoking.\n");
      }
    }

    /*Implement the smoker with paper*/
    else
    {
      smkr_pap_PID = fork();

      if (smkr_pap_PID == -1)
      {
        perror("Forking smoker with paper");
        exit(EXIT_FAILURE);
      }

      else if (smkr_pap_PID == 0)
      {
        printf("SMOKER WITH PAPER created (PID = %d).\n", getpid());
        while(done == false)
        {
          P(smkr_paper);
          P(lock);
          printf("SMOKER WITH PAPER picks up tobacoo and matches from the table.\n");
          V(agent);
          V(lock);
          printf("SMOKER WITH PAPER begins smoking.\n");
        }
      }

      /*Implement the smoker with matches*/
      else
      {
        smkr_mat_PID = fork();

        if (smkr_mat_PID == -1)
        {
          perror("Forking smoker with matches");
          exit(EXIT_FAILURE);
        }

        else if (smkr_mat_PID == 0)
        {
          printf("SMOKER WITH MATCHES created (PID = %d).\n", getpid());
          while(done == false)
          {
            P(smkr_matches);
            P(lock);
            printf("SMOKER WITH MATCHES picks up tobacco and paper from the table.\n");
            V(agent);
            V(lock);
            printf("SMOKER WITH MATCHES begins smoking.\n");
          }
        }

        else
        {
          pid = wait(&status);
          printf("PID = %d terminated with status = %d\n.", pid, status);

          pid = wait(&status);
          printf("PID = %d terminated with status = %d\n.", pid, status);

          pid = wait(&status);
          printf("PID = %d terminated with status = %d\n.", pid, status);

          pid = wait(&status);
          printf("PID = %d terminated with status = %d\n.", pid, status);
        }
        exit(EXIT_SUCCESS);
      }
      exit(EXIT_SUCCESS);
    }
    exit(EXIT_SUCCESS);
  }
  exit(EXIT_SUCCESS);
}
</code>```

I ran my solution through a debugger and noticed that the bug occurs when the second wait() call towards the end of the program is made. In executing that wait() call, it seems that my program runs forever. I suspected that an infinite loop was occurring in one of the smoker processes. After reviewing my code further, I noticed that, although the agent process seems to terminate normally in the first wait() call, the boolean variable done does not change its value to true as intended. This could explain why there seems to be an infinite loop.

In attempting to understand why the bug was happening, I tried several changes to the code, but all of them failed to correct the bug. The following is a list of what I tried and the rationale for trying it:

1. Changing the initial value of done from false to true.

My solution initializes done to false. I reasoned that, during execution, if one of the smoker processes started first, perhaps their while-loops would run forever. However, I realized the while-loops could not run forever because the P() operation would block the smoker process. Nevertheless, I changed the initial value of done to true to confirm my reasoning.

2. Having the agent process acquire the lock before assigning true to done.

As mentioned earlier, I noticed that the agent process terminated normally without changing the value of done to true. In an attempt to correct that, I changed the solution to have the agent acquire the lock one more time before changing the value of done and then releasing the lock again to allow the smoker processes to do work.

3. In the implementations of the smoker processes, releasing the lock before incrementing the agent semaphore.

In the while-loops of the smoker processes, after a smoker picks up the ingredients from the table, the agent semaphore is incremented before the lock is released. My instructor suggested that this order of operations could cause a deadlock and advised that I swap the order, releasing the lock first before incrementing the agent semaphore.

4. In the implementation of the agent process, releasing the lock before incrementing the semaphore of a smoker process.

Similar to what happens in the while-loop of the smoker processes, after the agent process randomly selects two ingredients and places them on the table, the agent increments the semaphore of the corresponding smoker process and then releases the lock. I wanted to see what would happen if I applied my instructor's suggestion to the agent process, so I changed the code so that the agent releases the lock before incrementing the semaphore of the smoker process.

The following additional information may be helpful in answering this problem:

The sem.h header file included at the beginning of the code works fine. However, if you would like to see it, here it is:

```<code>/************************************************************************/
/*  Operating Systems - Fall
/*      Originally developed at KSU by a teaching assistant             */
/*                                  */
/*      Description :  The following library is a collection of         */
/*                     routines for using binary semaphores in C:       */
/*          1. seminit - to initialize a semaphore.         */
/*          2. P - to perform a P(S) (wait) operation.      */
/*          3. V - to perform a V(S) (signal) operation.    */
/*          4. semkill - to remove a semaphore              */
/*                                                          */
/*             These routines call system routines:     */
/*          1. semget - to get a semaphore          */
/*          2. semctl - semaphore control operations    */
/*          3. semop  - semaphore operations        */
/*                                  */
/*             Complete manual entries can be obtained by:      */
/*          man semctl | col -b | lpr           */
/************************************************************************/

#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>

union arg{          /* This structure is used to call semctl */
    int val;
    struct semid_ds *buf;
    char *array;
};

/*
 * Create semaphore based on "key" parameter to "initval"
 */

void sem_create(int semid, int initval)
{
    int semval;
    union semun
    {
        int val;
        struct semid_ds *buf;
        unsigned short *array;
    }s;

    s.val=initval;
    if((semval=semctl(semid,0,SETVAL,s))<0)
    printf("\n Erroe in executing semctl");
}

/*
 * Remove semaphore with semaphore id (sid) from the kernel
 */
static void semkill(int sid)
{

    if (semctl(sid,0,IPC_RMID,0) == -1)
        perror("semctl (kill)");

    printf("Semaphore with value of sid = %d is killed \n",sid);

}

/*
 * Perform the designated "op" operation on the semaphore. If "op" is -1,
 * then this implements the "P" operation; it decrements the value of the
 * semaphore (semval) if it was >0,
 * and blocks the caller if it was zero (semval==0)
 * If "op" is 1, then this is simply added to current value of
 * the semaphore ("V" operation).
 */
static void semcall(int sid, int op)
{

    struct sembuf sb;

    sb.sem_num = 0; /* semaphore number within sid */
    sb.sem_op = op;
    sb.sem_flg = 0; /* blocking call */
    if (semop(sid, &sb, 1) == -1)
        perror("semop");

}

/*
 * P operation on semaphore "sid". Should be called upon entry to critical
 * region.
 */
static void P(int sid) {

    semcall(sid, -1);

}

/*
 * V operation on semaphore "sid". Should be called upon exit from critical
 * region.
 */
static void V(int sid) {

    semcall(sid, 1);

}

</code>```

I wrote my code in Microsoft Visual Studio using Ubuntu within a Virtual Box VM.

Finally, my question is: why does my solution not terminate?

Thank you for your time.

Body:
I wrote a solution to The Cigarette Smoker's Problem that does not terminate.

A full description of the problem and pseudo-code for the solution can be found here. Briefly, the task is to synchronize four processes using semaphores.

I used the pseudo-code as a guide for writing my solution. The following is my C implementation of the solution:

#include "sem.h"      //Allows the use of semget(), sem_create(), and the P() and V() functions.
#include <stdlib.h>   //Allows the use of srand() and rand().
#include <time.h>     //Allows the use of time().
#include <stdbool.h>  //Allows the use of the boolean variable that terminates smoker processes
#include <unistd.h>   //Allows the use of fork().
#include <sys/wait.h> //Allows the use of waitpid().

int main()
{

  /*Create and initialize semaphores*/
  int smkr_matches = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT); // Smoker that has matches
  int smkr_tobacco = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT); // Smoker that has tobacco
  int smkr_paper = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT);   // Smoker that has paper
  int agent = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT);
  int lock = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT); // The mutex variable

  /*According to http://www.cs.umd.edu/~hollings/cs412/s96/synch/smokers.html,
    all semaphores are initialized to zero except "lock", which is initialized to one.
  */
  sem_create(smkr_matches, 0);
  sem_create(smkr_tobacco, 0);
  sem_create(smkr_paper, 0);
  sem_create(agent, 0);
  sem_create(lock, 1);

  /*Seed the random number generator to generate random choice of ingredients.*/
  srand(time(NULL));

  // Delcare a boolean variable to terminate the smoker processes.
  bool done = false;

  //Declare variables to store PID after wait() calls and status.
  int pid = 0;
  int status = 0;

  /*Declare variables to store PIDs.*/
  int smkr_mat_PID = 0;
  int smkr_tob_PID = 0;
  int smkr_pap_PID = 0;
  int agent_PID = 0;

  /*Implement the agent process*/
  agent_PID = fork();

  if (agent_PID == -1)
  { // Forking the agent process failed
    perror("Forking the agent process");
    exit(EXIT_FAILURE);
  }

  else if (agent_PID == 0)
  {
    printf("AGENT process created (PID = %d).\n", getpid());
    int rand_num = 0;
    for (int i = 0; i < 4; i++)
    { // Agent will place items on table ten times.
      P(lock);

      // Randomly choose a pair of ingredients.
      rand_num = (rand() % 3) + 1;

      // Place the ingredients on the table and wake the appropriate smoker.
      if (rand_num == 1)
      {
        printf("AGENT has placed TOBACCO and PAPER on the table.\n");
        printf("AGENT wakes smoker with MATCHES.\n");
        V(smkr_matches);
      }
      else if (rand_num == 2)
      {
        printf("AGENT has placed TOBACCO and MATCHES on the table.\n");
        printf("AGENT wakes smoker with PAPER.\n");
        V(smkr_paper);
      }
      else if (rand_num == 3)
      {
        printf("AGENT places MATCHES and PAPER on the table.\n");
        printf("AGENT wakes smoker with TOBACCO.\n");
        V(smkr_tobacco);
      }

      // Allow the smoker to work
      V(lock);

      printf("AGENT will now sleep.\n");
      P(agent);
    }

    done = true;
  }

  /*Implement the smoker with tobacco*/
  else
  {
    smkr_tob_PID = fork();

    if (smkr_tob_PID == -1)
    {
      perror("Forking smoker with tobacco");
      exit(EXIT_FAILURE);
    }

    else if (smkr_tob_PID == 0)
    {
      printf("SMOKER WITH TOBACCO created. (PID = %d)\n", getpid());
      while(done == false)
      {
        P(smkr_tobacco);
        P(lock);
        printf("SMOKER WITH TOBACCO picks up matches and paper from the table.\n");
        V(agent);
        V(lock);
        printf("SMOKER WITH TOBACCO begins smoking.\n");
      }
    }

    /*Implement the smoker with paper*/
    else
    {
      smkr_pap_PID = fork();

      if (smkr_pap_PID == -1)
      {
        perror("Forking smoker with paper");
        exit(EXIT_FAILURE);
      }

      else if (smkr_pap_PID == 0)
      {
        printf("SMOKER WITH PAPER created (PID = %d).\n", getpid());
        while(done == false)
        {
          P(smkr_paper);
          P(lock);
          printf("SMOKER WITH PAPER picks up tobacoo and matches from the table.\n");
          V(agent);
          V(lock);
          printf("SMOKER WITH PAPER begins smoking.\n");
        }
      }

      /*Implement the smoker with matches*/
      else
      {
        smkr_mat_PID = fork();

        if (smkr_mat_PID == -1)
        {
          perror("Forking smoker with matches");
          exit(EXIT_FAILURE);
        }

        else if (smkr_mat_PID == 0)
        {
          printf("SMOKER WITH MATCHES created (PID = %d).\n", getpid());
          while(done == false)
          {
            P(smkr_matches);
            P(lock);
            printf("SMOKER WITH MATCHES picks up tobacco and paper from the table.\n");
            V(agent);
            V(lock);
            printf("SMOKER WITH MATCHES begins smoking.\n");
          }
        }

        else
        {
          pid = wait(&status);
          printf("PID = %d terminated with status = %d\n.", pid, status);

          pid = wait(&status);
          printf("PID = %d terminated with status = %d\n.", pid, status);

          pid = wait(&status);
          printf("PID = %d terminated with status = %d\n.", pid, status);

          pid = wait(&status);
          printf("PID = %d terminated with status = %d\n.", pid, status);
        }
        exit(EXIT_SUCCESS);
      }
      exit(EXIT_SUCCESS);
    }
    exit(EXIT_SUCCESS);
  }
  exit(EXIT_SUCCESS);
}

I ran my solution through a debugger and noticed that the bug occurs when the second wait() call towards the end of the program is made. In executing that wait() call, it seems that my program runs forever. I suspected that an infinite loop was occurring in one of the smoker processes. After reviewing my code further, I noticed that, although the agent process seems to terminate normally in the first wait() call, the boolean variable done does not change its value to true as intended. This could explain why there seems to be an infinite loop.

In attempting to understand why the bug was happening, I tried several changes to the code, but all of them failed to correct the bug. The following is a list of what I tried and the rationale for trying it:

1. Changing the initial value of done from false to true.

My solution initializes done to false. I reasoned that, during execution, if one of the smoker processes started first, perhaps their while-loops would run forever. However, I realized the while-loops could not run forever because the P() operation would block the smoker process. Nevertheless, I changed the initial value of done to true to confirm my reasoning.

2. Having the agent process acquire the lock before assigning true to done.

As mentioned earlier, I noticed that the agent process terminated normally without changing the value of done to true. In an attempt to correct that, I changed the solution to have the agent acquire the lock one more time before changing the value of done and then releasing the lock again to allow the smoker processes to do work.

3. In the implementations of the smoker processes, releasing the lock before incrementing the agent semaphore.

In the while-loops of the smoker processes, after a smoker picks up the ingredients from the table, the agent semaphore is incremented before the lock is released. My instructor suggested that this order of operations could cause a deadlock and advised that I swap the order, releasing the lock first before incrementing the agent semaphore.

4. In the implementation of the agent process, releasing the lock before incrementing the semaphore of a smoker process.

Similar to what happens in the while-loop of the smoker processes, after the agent process randomly selects two ingredients and places them on the table, the agent increments the semaphore of the corresponding smoker process and then releases the lock. I wanted to see what would happen if I applied my instructor's suggestion to the agent process, so I changed the code so that the agent releases the lock before incrementing the semaphore of the smoker process.

The following additional information may be helpful in answering this problem:

The sem.h header file included at the beginning of the code works fine. However, if you would like to see it, here it is:

/************************************************************************/
/*  Operating Systems - Fall
/*      Originally developed at KSU by a teaching assistant             */
/*                                  */
/*      Description :  The following library is a collection of         */
/*                     routines for using binary semaphores in C:       */
/*          1. seminit - to initialize a semaphore.         */
/*          2. P - to perform a P(S) (wait) operation.      */
/*          3. V - to perform a V(S) (signal) operation.    */
/*          4. semkill - to remove a semaphore              */
/*                                                          */
/*             These routines call system routines:     */
/*          1. semget - to get a semaphore          */
/*          2. semctl - semaphore control operations    */
/*          3. semop  - semaphore operations        */
/*                                  */
/*             Complete manual entries can be obtained by:      */
/*          man semctl | col -b | lpr           */
/************************************************************************/

#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>

union arg{          /* This structure is used to call semctl */
    int val;
    struct semid_ds *buf;
    char *array;
};

/*
 * Create semaphore based on "key" parameter to "initval"
 */

void sem_create(int semid, int initval)
{
    int semval;
    union semun
    {
        int val;
        struct semid_ds *buf;
        unsigned short *array;
    }s;

    s.val=initval;
    if((semval=semctl(semid,0,SETVAL,s))<0)
    printf("\n Erroe in executing semctl");
}

/*
 * Remove semaphore with semaphore id (sid) from the kernel
 */
static void semkill(int sid)
{

    if (semctl(sid,0,IPC_RMID,0) == -1)
        perror("semctl (kill)");

    printf("Semaphore with value of sid = %d is killed \n",sid);

}

/*
 * Perform the designated "op" operation on the semaphore. If "op" is -1,
 * then this implements the "P" operation; it decrements the value of the
 * semaphore (semval) if it was >0,
 * and blocks the caller if it was zero (semval==0)
 * If "op" is 1, then this is simply added to current value of
 * the semaphore ("V" operation).
 */
static void semcall(int sid, int op)
{

    struct sembuf sb;

    sb.sem_num = 0; /* semaphore number within sid */
    sb.sem_op = op;
    sb.sem_flg = 0; /* blocking call */
    if (semop(sid, &sb, 1) == -1)
        perror("semop");

}

/*
 * P operation on semaphore "sid". Should be called upon entry to critical
 * region.
 */
static void P(int sid) {

    semcall(sid, -1);

}

/*
 * V operation on semaphore "sid". Should be called upon exit from critical
 * region.
 */
static void V(int sid) {

    semcall(sid, 1);

}

I wrote my code in Microsoft Visual Studio using Ubuntu within a Virtual Box VM.

Finally, my question is: why does my solution not terminate?

Thank you for your time.


问:
VueJs POST with fetch not sending data to firebase cloud function
I'm trying to send a POST request to a firebase cloud function from Vue.js 3 but I can't seem to get the data to actually send.

Here is the code I am using to make the request

```<code>const requestOptions = {
   method: 'POST',
   headers: { 'Content-Type': 'application/json' },
   body: JSON.stringify({ name: name, gender: gender })
};

await fetch('...url/to/function/helloWorld', requestOptions)
    .then(async response => {
         const data = await response.json();
         console.log(data)
     }
})
</code>```

In the cloud function I have:

```<code>exports.helloWorld = functions.https.onRequest((req, res) => {

    cors(req, res, () => {

        const name = req.query.name
        const gender = req.query.gender

        functions.logger.log("Req: ", req.body.name);
        functions.logger.log("name: ", name);
        functions.logger.log("gender: ", gender);

        const response = {
            name: name,
            gender: gender
        }
        res.send(response)
    })
});
</code>```

When I check the google firebase logs, I see this:

When I check the console log. I get 204 response.

I have added some dummy information into the body to check if it was the variables not been set like so:

```<code>body: JSON.stringify({ name: "name", gender:"gender" })
</code>```

But that doesn't do anything either.

What am I doing wrong?

EDIT:

Here is the full index.js file for the cloud function

```<code>const functions = require("firebase-functions");
// IMPORTANTO
// REMOVE CORS FROM THIS, ONLY USED FOR TESTING
const cors = require('cors')({ origin: true });

exports.helloWorld = functions.https.onRequest((req, res) => {

        cors(req, res, () => {

            const name = req.body.name
            const gender = req.body.gender

            functions.logger.log("Req: ", req.body.name);
            functions.logger.log("name: ", name);
            functions.logger.log("gender: ", gender);

            const response = {
                name: name,
                gender: gender
            }
            res.send(response)
        })
});
</code>```

EDIT: Payload information.

The function is called 2 times in the console.

1 with status 200 and fetch
2 with status 204 and preflight

The one with 200 has no payload. The one with 204 has the following:

Body:
I'm trying to send a POST request to a firebase cloud function from Vue.js 3 but I can't seem to get the data to actually send.

Here is the code I am using to make the request

const requestOptions = {
   method: 'POST',
   headers: { 'Content-Type': 'application/json' },
   body: JSON.stringify({ name: name, gender: gender })
};

await fetch('...url/to/function/helloWorld', requestOptions)
    .then(async response => {
         const data = await response.json();
         console.log(data)
     }
})

In the cloud function I have:

exports.helloWorld = functions.https.onRequest((req, res) => {

    cors(req, res, () => {

        const name = req.query.name
        const gender = req.query.gender

        functions.logger.log("Req: ", req.body.name);
        functions.logger.log("name: ", name);
        functions.logger.log("gender: ", gender);

        const response = {
            name: name,
            gender: gender
        }
        res.send(response)
    })
});

When I check the google firebase logs, I see this:

When I check the console log. I get 204 response.

I have added some dummy information into the body to check if it was the variables not been set like so:

body: JSON.stringify({ name: "name", gender:"gender" })

But that doesn't do anything either.

What am I doing wrong?

EDIT:

Here is the full index.js file for the cloud function

const functions = require("firebase-functions");
// IMPORTANTO
// REMOVE CORS FROM THIS, ONLY USED FOR TESTING
const cors = require('cors')({ origin: true });

exports.helloWorld = functions.https.onRequest((req, res) => {

        cors(req, res, () => {

            const name = req.body.name
            const gender = req.body.gender

            functions.logger.log("Req: ", req.body.name);
            functions.logger.log("name: ", name);
            functions.logger.log("gender: ", gender);

            const response = {
                name: name,
                gender: gender
            }
            res.send(response)
        })
});

EDIT: Payload information.

The function is called 2 times in the console.

1 with status 200 and fetch
2 with status 204 and preflight

The one with 200 has no payload. The one with 204 has the following:


问:
nodemon is not starting windows 11
I run the following command in my terminal:

```<code>npm install -g nodemon
</code>```

but whenever i starting nodemon by nodemon index.js  , it's showing me the following error:

```<code>nodemon : File C:\Users\****\****\Roaming\npm\nodemon.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
nodemon index.js

CategoryInfo          : SecurityError: (:) [], PSSecurityException
FullyQualifiedErrorId : UnauthorizedAccess
>
</code>```

My package.json file is:

```<code>{
  "name": "gfg-express",
  "version": "1.0.0",
  "description": "How to connect express with mongodb atlas",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Greyhat07",
  "license": "ISC",
  "dependencies": {
    "express": "^4.18.2"
  }
}

</code>```

solution, that is how to solve this problem

Title: nodemon is not starting windows 11

Body:
I run the following command in my terminal:

npm install -g nodemon

but whenever i starting nodemon by nodemon index.js  , it's showing me the following error:

nodemon : File C:\Users\****\****\Roaming\npm\nodemon.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
nodemon index.js

CategoryInfo          : SecurityError: (:) [], PSSecurityException
FullyQualifiedErrorId : UnauthorizedAccess
>

My package.json file is:

{
  "name": "gfg-express",
  "version": "1.0.0",
  "description": "How to connect express with mongodb atlas",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Greyhat07",
  "license": "ISC",
  "dependencies": {
    "express": "^4.18.2"
  }
}

solution, that is how to solve this problem


问:
CGAL namespace does not contain data_file_path function
I am using xubuntu20.04 and trying out to compile an example of cgal. for reference, I am working with AABB_tree. CGAL is header only so I copied the include folder to AABB_tree directory. Followed this instruction. when I run make this error is generated-

```<code>Scanning dependencies of target AABB_segment_3_example
[  3%] Building CXX object CMakeFiles/AABB_segment_3_example.dir/AABB_segment_3_example.cpp.o
[  7%] Linking CXX executable AABB_segment_3_example
[  7%] Built target AABB_segment_3_example
Scanning dependencies of target AABB_custom_indexed_triangle_set_array_example
[ 10%] Building CXX object CMakeFiles/AABB_custom_indexed_triangle_set_array_example.dir/AABB_custom_indexed_triangle_set_array_example.cpp.o
[ 14%] Linking CXX executable AABB_custom_indexed_triangle_set_array_example
[ 14%] Built target AABB_custom_indexed_triangle_set_array_example
Scanning dependencies of target AABB_polyhedron_facet_distance_example
[ 17%] Building CXX object CMakeFiles/AABB_polyhedron_facet_distance_example.dir/AABB_polyhedron_facet_distance_example.cpp.o
[ 21%] Linking CXX executable AABB_polyhedron_facet_distance_example
[ 21%] Built target AABB_polyhedron_facet_distance_example
Scanning dependencies of target AABB_halfedge_graph_edge_example
[ 25%] Building CXX object CMakeFiles/AABB_halfedge_graph_edge_example.dir/AABB_halfedge_graph_edge_example.cpp.o
[ 28%] Linking CXX executable AABB_halfedge_graph_edge_example
[ 28%] Built target AABB_halfedge_graph_edge_example
Scanning dependencies of target AABB_cached_bbox_example
[ 32%] Building CXX object CMakeFiles/AABB_cached_bbox_example.dir/AABB_cached_bbox_example.cpp.o
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp: In function ‘void triangle_mesh(std::string)’:
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp:30:17: error: ‘read_polygon_mesh’ is not a member of ‘CGAL::IO’
   30 |   if(!CGAL::IO::read_polygon_mesh(fname, tmesh) || CGAL::is_triangle_mesh(tmesh))
      |                 ^~~~~~~~~~~~~~~~~
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp: In function ‘int main(int, char**)’:
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp:86:54: error: ‘data_file_path’ is not a member of ‘CGAL’
   86 |   triangle_mesh<Polyhedron_3>((argc>1)?argv[1]:CGAL::data_file_path("meshes/tetrahedron.off"));
      |                                                      ^~~~~~~~~~~~~~
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp:89:54: error: ‘data_file_path’ is not a member of ‘CGAL’
   89 |   triangle_mesh<Surface_mesh>((argc>1)?argv[1]:CGAL::data_file_path("meshes/tetrahedron.off"));
      |                                                      ^~~~~~~~~~~~~~
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp:92:50: error: ‘data_file_path’ is not a member of ‘CGAL’
   92 |   surface_mesh_cache_bbox((argc>1)?argv[1]:CGAL::data_file_path("meshes/tetrahedron.off"));
      |                                                  ^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/AABB_cached_bbox_example.dir/build.make:63: CMakeFiles/AABB_cached_bbox_example.dir/AABB_cached_bbox_example.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:266: CMakeFiles/AABB_cached_bbox_example.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
</code>```

It looks like cgal namespace does not include a data_file_path function. How to fix the problem? Is there any linking problem exist?

I have copied the meshes/tetrahedron.off to the AABB_tree directory. Since the function does not exist, no way to read it.

Body:
I am using xubuntu20.04 and trying out to compile an example of cgal. for reference, I am working with AABB_tree. CGAL is header only so I copied the include folder to AABB_tree directory. Followed this instruction. when I run make this error is generated-

Scanning dependencies of target AABB_segment_3_example
[  3%] Building CXX object CMakeFiles/AABB_segment_3_example.dir/AABB_segment_3_example.cpp.o
[  7%] Linking CXX executable AABB_segment_3_example
[  7%] Built target AABB_segment_3_example
Scanning dependencies of target AABB_custom_indexed_triangle_set_array_example
[ 10%] Building CXX object CMakeFiles/AABB_custom_indexed_triangle_set_array_example.dir/AABB_custom_indexed_triangle_set_array_example.cpp.o
[ 14%] Linking CXX executable AABB_custom_indexed_triangle_set_array_example
[ 14%] Built target AABB_custom_indexed_triangle_set_array_example
Scanning dependencies of target AABB_polyhedron_facet_distance_example
[ 17%] Building CXX object CMakeFiles/AABB_polyhedron_facet_distance_example.dir/AABB_polyhedron_facet_distance_example.cpp.o
[ 21%] Linking CXX executable AABB_polyhedron_facet_distance_example
[ 21%] Built target AABB_polyhedron_facet_distance_example
Scanning dependencies of target AABB_halfedge_graph_edge_example
[ 25%] Building CXX object CMakeFiles/AABB_halfedge_graph_edge_example.dir/AABB_halfedge_graph_edge_example.cpp.o
[ 28%] Linking CXX executable AABB_halfedge_graph_edge_example
[ 28%] Built target AABB_halfedge_graph_edge_example
Scanning dependencies of target AABB_cached_bbox_example
[ 32%] Building CXX object CMakeFiles/AABB_cached_bbox_example.dir/AABB_cached_bbox_example.cpp.o
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp: In function ‘void triangle_mesh(std::string)’:
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp:30:17: error: ‘read_polygon_mesh’ is not a member of ‘CGAL::IO’
   30 |   if(!CGAL::IO::read_polygon_mesh(fname, tmesh) || CGAL::is_triangle_mesh(tmesh))
      |                 ^~~~~~~~~~~~~~~~~
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp: In function ‘int main(int, char**)’:
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp:86:54: error: ‘data_file_path’ is not a member of ‘CGAL’
   86 |   triangle_mesh<Polyhedron_3>((argc>1)?argv[1]:CGAL::data_file_path("meshes/tetrahedron.off"));
      |                                                      ^~~~~~~~~~~~~~
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp:89:54: error: ‘data_file_path’ is not a member of ‘CGAL’
   89 |   triangle_mesh<Surface_mesh>((argc>1)?argv[1]:CGAL::data_file_path("meshes/tetrahedron.off"));
      |                                                      ^~~~~~~~~~~~~~
/home/alvi95/Personal/code/CGAL/examples/AABB_tree/AABB_cached_bbox_example.cpp:92:50: error: ‘data_file_path’ is not a member of ‘CGAL’
   92 |   surface_mesh_cache_bbox((argc>1)?argv[1]:CGAL::data_file_path("meshes/tetrahedron.off"));
      |                                                  ^~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/AABB_cached_bbox_example.dir/build.make:63: CMakeFiles/AABB_cached_bbox_example.dir/AABB_cached_bbox_example.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:266: CMakeFiles/AABB_cached_bbox_example.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

It looks like cgal namespace does not include a data_file_path function. How to fix the problem? Is there any linking problem exist?

I have copied the meshes/tetrahedron.off to the AABB_tree directory. Since the function does not exist, no way to read it.


问:
How to integrate jasper report in flutter mobile app?
I am searching for document how to connect or call or view jasper report from flutter mobile application but i was unable to find one. Hope community will help me out.
TIA</p>


问:
How to Reset the seekBar and disable it when another mediplayer is Running?
I have a List of Voice Recordings. Everything works well until, when one MediaPlayer is running and i clicked on another MediaPlayer without pausing the current one, seekbar of the current MediaPlayer also runs with the new MediaPlayer.

I tried everything possible i could from setting certain conditions to it but nothing is really working.
Please anyone there to Help me!


问:
How to get the address of the previous page in golang from the headers? My "Referer" header is empty
`

```<code>func temp(c *gin.Context) {
   tmp, _ := template.ParseFiles("index.html")
   err := tmp.Execute(c.Writer, "")

   println(c.Request.Header.Get("Referer"))

   if err != nil {
      return
   }
}
</code>```

`

This code prints headers, but it doesn't have "Referer"
`

```<code>requestDump, err := httputil.DumpRequest(c.Request, true)
println(string(requestDump))
</code>```

`

Body:
`

func temp(c *gin.Context) {
   tmp, _ := template.ParseFiles("index.html")
   err := tmp.Execute(c.Writer, "")

   println(c.Request.Header.Get("Referer"))

   if err != nil {
      return
   }
}

`

This code prints headers, but it doesn't have "Referer"
`

requestDump, err := httputil.DumpRequest(c.Request, true)
println(string(requestDump))

`


问:
Excel formula is breaking from XML spread sheet when special character is used in the downloaded excel file
My formula in the downloaded excel file is breaking from XML spread sheet which has the formula(concatenating 2 strings with hypen in between)
ss:Formula="=RC[17]&"m x "&RC[18]&"m"">

I tried using header  and also tried adding &#38 and &#34 in place of amp and quot but excel is throwing error saying bad formula found and it is unable to translate &" into &"


问:
asking user for input and getting it from the terminal in c using getchar()
I am trying to ask a user for a string of input and then get that input from the terminal. Here is my code but it is not working(it doesn't ask user for input).

```<code>printf("Enter search string or X to exit:\n");
char str[1024] = " ";
   char h;
   int j = 0;
   while( (h = getchar()) != '\n'){
   str[j++] = h;
   str[j] = '\0';
}
</code>```

Should be giving a user input

Body:
I am trying to ask a user for a string of input and then get that input from the terminal. Here is my code but it is not working(it doesn't ask user for input).

printf("Enter search string or X to exit:\n");
char str[1024] = " ";
   char h;
   int j = 0;
   while( (h = getchar()) != '\n'){
   str[j++] = h;
   str[j] = '\0';
}

Should be giving a user input


问:
How can I differentiate function type expressions in Typescript?
I'm new to Typescript and I've run across a snag with type guards and differentiating types. Lets say I have the following types:

```<code>type TypeA: (foo: Foo) => string

type TypeB: (bar: Bar) => number

type TypeAB: TypeA | TypeB
</code>```

If I have a higher order function and I'm passing a TypeAB as a parameter, how would I check whether this is of TypeA or TypeB?

I suppose I could do the following:

```<code>type TypeA: {
   useFoo: (foo: Foo) => string
}

type TypeB: {
   useBar: (bar: Bar) => number
}

type TypeAB: TypeA | TypeB

function isTypeA(ab: TypeAB): operation is TypeA {
    return "useFoo" in (ab as TypeA)
}

function isTypeB(ab: TypeAB): operation is TypeB {
    return "useBar" in (ab as TypeB)
}

function doSomething(ab: TypeAB) {
   if (isTypeA(ab)) {
      // Do something to get string
   } else if (isTypeB(ab)) {
      // Do something to get number
   } else {
      // Throw an error? Or have a fallback plan
   }
}
</code>```

But if I am going to be passing around lots of TypeABs, it's going to be tedious to wrap the functions in these objects every time.

I tried to see if there was a way to get check whether certain arguments were present, but came up shorthanded. I also read up on type predicates as described here https://www.typescriptlang.org/docs/handbook/2/narrowing.html

Body:
I'm new to Typescript and I've run across a snag with type guards and differentiating types. Lets say I have the following types:

type TypeA: (foo: Foo) => string

type TypeB: (bar: Bar) => number

type TypeAB: TypeA | TypeB

If I have a higher order function and I'm passing a TypeAB as a parameter, how would I check whether this is of TypeA or TypeB?

I suppose I could do the following:

type TypeA: {
   useFoo: (foo: Foo) => string
}

type TypeB: {
   useBar: (bar: Bar) => number
}

type TypeAB: TypeA | TypeB

function isTypeA(ab: TypeAB): operation is TypeA {
    return "useFoo" in (ab as TypeA)
}

function isTypeB(ab: TypeAB): operation is TypeB {
    return "useBar" in (ab as TypeB)
}

function doSomething(ab: TypeAB) {
   if (isTypeA(ab)) {
      // Do something to get string
   } else if (isTypeB(ab)) {
      // Do something to get number
   } else {
      // Throw an error? Or have a fallback plan
   }
}

But if I am going to be passing around lots of TypeABs, it's going to be tedious to wrap the functions in these objects every time.

I tried to see if there was a way to get check whether certain arguments were present, but came up shorthanded. I also read up on type predicates as described here https://www.typescriptlang.org/docs/handbook/2/narrowing.html


问:
How to create or hack the noise reduction model for audio processing python
I have been working on NLP project and Now I need to create Speech-to-text model for that

but my dataset is noisy and I have to create the noise reduction to train my Speech-to-text model

my go is to change some of this items

```<code>optimization = {
    'amplify': '2.2 dB',
    'bass': '9.0 dB',
    'treble': '-1.0 dB',
    'volume': '1.0 dB',
    'speed': '0.98',
    'high-pass': {
        'frequency': '1000 Hz',
        'roll-off': '6dB per octave',
    },
    'low-pass': {
        'frequency': '1000 Hz',
        'roll-off': '6dB per octave',
    },
    'snap-to': 'nearest',
    'quality': 'insane-320 kbps',
    'variable-speed': 'standard',
    'chanel-mode': 'joint-stereo',
    'rate': '16000 HZ',
}
</code>```

so what should I learn first

Body:
I have been working on NLP project and Now I need to create Speech-to-text model for that

but my dataset is noisy and I have to create the noise reduction to train my Speech-to-text model

my go is to change some of this items

optimization = {
    'amplify': '2.2 dB',
    'bass': '9.0 dB',
    'treble': '-1.0 dB',
    'volume': '1.0 dB',
    'speed': '0.98',
    'high-pass': {
        'frequency': '1000 Hz',
        'roll-off': '6dB per octave',
    },
    'low-pass': {
        'frequency': '1000 Hz',
        'roll-off': '6dB per octave',
    },
    'snap-to': 'nearest',
    'quality': 'insane-320 kbps',
    'variable-speed': 'standard',
    'chanel-mode': 'joint-stereo',
    'rate': '16000 HZ',
}

so what should I learn first


问:
How to multiply the values of two objects i.e. slider and number input in Javascript
I want multiply the values of two objects in javascript and want to show in innerHtml of rangeV, But I am getting issues. Please help. The code is given below. Also, I have attached a picture of code and highlighted the issue.

const range = document.getElementById("range"),
  rangeV = document.getElementById("rangeV"),
  inp5 = document.getElementById("myinput"),
  inp6 = inp5.value,
  inp7 = 2;

setValue = () => {
  const newValue = Number(
      ((range.value - range.min) * 100) / (range.max - range.min)
    ),
    newPosition = 10 - newValue * 0.2;
  var val1 = range.value * inp7;
  rangeV.innerHTML = `<span>${val1}</span>`;
  rangeV.style.left = `calc(${newValue}% + (${newPosition}px))`;

  // $(".forspace").html(range.value);
};

document.addEventListener("DOMContentLoaded", setValue);
range.addEventListener("input", setValue);```