问:
Redis seems to be evicting read group, but not stream
I've had a hard time cracking this over the past couple of hours, and could really use any advice.

In our application--which uses the python client for redis communication--we're encountering a runtime error that occurs usually after about 30 to 45 minutes. The runtime error appears as follows:

```<code>Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     self.read_task_stream(event_hash)
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/gdg_model_builder/model/model.py", line 563, in read_task_stream
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     for resp in self.store.xreadgroup(self.model_hostname, self.consumer_id, {
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/commands/core.py", line 3849, in xreadgroup
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return self.execute_command("XREADGROUP", *pieces)
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/client.py", line 1238, in execute_command
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return conn.retry.call_with_retry(
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/retry.py", line 46, in call_with_retry
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return do()
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/client.py", line 1239, in <lambda>
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     lambda: self._send_command_parse_response(
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/client.py", line 1215, in _send_command_parse_response
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return self.parse_response(conn, command_name, **options)
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/client.py", line 1254, in parse_response
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     response = connection.read_response()
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/connection.py", line 839, in read_response
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     raise response
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]: redis.exceptions.ResponseError: NOGROUP No such key '0:$c53c9a917d96fb20d07a44ed9c7660e2cde4dd631301d32fb14c0a789248bbed' or consumer group '0' in XREADGROUP with GROUP option
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]: ERROR:root:NOGROUP No such key '0:$6c86128ec579c0d5c3fcb2a1bcb66b2e13b48f447b8f22223fce0f632ffb8bb2' or consumer group '0' in XREADGROUP with GROUP option
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]: Traceback (most recent call last):
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/gdg_model_builder/model/model.py", line 599, in _listen_task
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     self.read_task_stream(event_hash)
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/gdg_model_builder/model/model.py", line 563, in read_task_stream
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     for resp in self.store.xreadgroup(self.model_hostname, self.consumer_id, {
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/commands/core.py", line 3849, in xreadgroup
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return self.execute_command("XREADGROUP", *pieces)
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/client.py", line 1238, in execute_command
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return conn.retry.call_with_retry(
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/retry.py", line 46, in call_with_retry
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return do()
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/client.py", line 1239, in <lambda>
</code>```

This service runs part of a distributed event loop and makes available some state stored in a Redis cluster. When a particular member boots up, it listens for events pushed to any number of hashes and handles them accordingly. However, as we debug, we're listening for events on a single client.

We know the group gets created appropriately--at first--because events that happen within the first thirty to forty-five minutes, including the one above are handled correctly. We believe this to be dependent on the environment we're working in because none of us has successfully replicated the problem locally. We're running on Ubuntu 18.04 in GCP.

We've tried debugging this a couple different environments on our servers. (1) Nomad scheduler running Docker containers. (2) Docker container for redis, application backend running barebones. Both experience the same issue, so I'm inclined to think this is something to do with the config that ships with the redis Docker image. No luck so far.

Any idea what might be going on?

Body:
I've had a hard time cracking this over the past couple of hours, and could really use any advice.

In our application--which uses the python client for redis communication--we're encountering a runtime error that occurs usually after about 30 to 45 minutes. The runtime error appears as follows:

Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     self.read_task_stream(event_hash)
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/gdg_model_builder/model/model.py", line 563, in read_task_stream
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     for resp in self.store.xreadgroup(self.model_hostname, self.consumer_id, {
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/commands/core.py", line 3849, in xreadgroup
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return self.execute_command("XREADGROUP", *pieces)
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/client.py", line 1238, in execute_command
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return conn.retry.call_with_retry(
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/retry.py", line 46, in call_with_retry
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return do()
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/client.py", line 1239, in <lambda>
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     lambda: self._send_command_parse_response(
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/client.py", line 1215, in _send_command_parse_response
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return self.parse_response(conn, command_name, **options)
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/client.py", line 1254, in parse_response
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     response = connection.read_response()
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/connection.py", line 839, in read_response
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     raise response
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]: redis.exceptions.ResponseError: NOGROUP No such key '0:$c53c9a917d96fb20d07a44ed9c7660e2cde4dd631301d32fb14c0a789248bbed' or consumer group '0' in XREADGROUP with GROUP option
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]: ERROR:root:NOGROUP No such key '0:$6c86128ec579c0d5c3fcb2a1bcb66b2e13b48f447b8f22223fce0f632ffb8bb2' or consumer group '0' in XREADGROUP with GROUP option
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]: Traceback (most recent call last):
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/gdg_model_builder/model/model.py", line 599, in _listen_task
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     self.read_task_stream(event_hash)
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/gdg_model_builder/model/model.py", line 563, in read_task_stream
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     for resp in self.store.xreadgroup(self.model_hostname, self.consumer_id, {
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/commands/core.py", line 3849, in xreadgroup
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return self.execute_command("XREADGROUP", *pieces)
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/client.py", line 1238, in execute_command
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return conn.retry.call_with_retry(
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/retry.py", line 46, in call_with_retry
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:     return do()
Dec 19 02:16:49 gcp-rpc-cluster-servers-dr34 python[30853]:   File "/home/me/backend/venv/lib/python3.10/site-packages/redis/client.py", line 1239, in <lambda>

This service runs part of a distributed event loop and makes available some state stored in a Redis cluster. When a particular member boots up, it listens for events pushed to any number of hashes and handles them accordingly. However, as we debug, we're listening for events on a single client.

We know the group gets created appropriately--at first--because events that happen within the first thirty to forty-five minutes, including the one above are handled correctly. We believe this to be dependent on the environment we're working in because none of us has successfully replicated the problem locally. We're running on Ubuntu 18.04 in GCP.

We've tried debugging this a couple different environments on our servers. (1) Nomad scheduler running Docker containers. (2) Docker container for redis, application backend running barebones. Both experience the same issue, so I'm inclined to think this is something to do with the config that ships with the redis Docker image. No luck so far.

Any idea what might be going on?


来源: stackexchange

问:
ffmpeg refuses to encode video
The command:

```<code>ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -resize 1920x1080 -i "Infinity.mkv" -vf "ass=Infinity.ass" -c:v h264_nvenc -preset slowest -crf 18 -c:a flac -af aformat=s32:48000 -compression_level 5 -strict -2 Infinity.mp4
</code>```

results in:

```<code>Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scale_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
Conversion failed!
</code>```

I tried adding hwupload and hwdownload to the vf filters. The result was the same.

ContentLicense: CC BY-SA 4.0

Title: ffmpeg refuses to encode video

Body:
The command:

ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -resize 1920x1080 -i "Infinity.mkv" -vf "ass=Infinity.ass" -c:v h264_nvenc -preset slowest -crf 18 -c:a flac -af aformat=s32:48000 -compression_level 5 -strict -2 Infinity.mp4

results in:

Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scale_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
Conversion failed!

I tried adding hwupload and hwdownload to the vf filters. The result was the same.


问:
Regex search all matches without discarding previously matched items
if I have a string
"2A3"
and I need to extract all combinations of
digit followed by letter
AND
letter followed by digit

so this should return
2A
and
A3

i tried
\d[A-Z]|[A-Z]\d
but it returns only 1 combination
How to fix this ?


问:
FormData with ExpressJS with image and body data
Hello I want to ask a question about using form data to send a file and also update data from user at the same time in ExpressJS. I want to ask if this could be handle all in one using form data (save image and update a profile information) through axios or should it be handle in two (two HTTP Requests)? For example:

```<code>formData.append('file', {
        uri: file.uri,
        type: file.type,
        name: file.name,
      });
// and append for example a updated info
formData.append('profileUpdate', {
            name: newName,
            email: newEmail,
            age: newAge,
          });
</code>```

then receive it on the express route side and separate each other or can you even do it with form-data request? or is there a way I can send the body apart on a PUT or POST Request (form-data)

Thank you in advance!

Body:
Hello I want to ask a question about using form data to send a file and also update data from user at the same time in ExpressJS. I want to ask if this could be handle all in one using form data (save image and update a profile information) through axios or should it be handle in two (two HTTP Requests)? For example:

formData.append('file', {
        uri: file.uri,
        type: file.type,
        name: file.name,
      });
// and append for example a updated info
formData.append('profileUpdate', {
            name: newName,
            email: newEmail,
            age: newAge,
          });

then receive it on the express route side and separate each other or can you even do it with form-data request? or is there a way I can send the body apart on a PUT or POST Request (form-data)

Thank you in advance!


问:
Sorting algorithm visulizer: how to highlight the current element being accessed and compared in the algorithm?
So im trying to write a sorting algorithm visualizer. Code bellow. I am basically using matplotlib to plot the figure. My problem is that i want to also highlight the current element in the array being accessed, compared, and swaped. all of my attempts have failed at this. Please do also let me know if there is a better way of writing a visulizer in python. I have seen some tutorials using pygame but wanted to stick to basics. Also when the program runs till the end and everthing is sorted the plot goes blank. Is this because of the plt.clf() command and is there a way for the sorted plot to not close. Thanks!!!

```<code>from matplotlib import pyplot as plt
import numpy as np

# generate sudo-random list of numbers
lst = np.random.randint(0, 100, 20)

# x values for the bar plot
x = range(0, len(lst))

def insertion_sort(lst):
# loop through the list
# incrementally check which index to the left should i be placed in
    for i in range(1, len(lst)):

        while lst[i-1] > lst[i] and i>0:

            lst[i], lst[i-1] = lst[i-1], lst[i]
            i = i-1

            # plot
            plt.bar(x,lst)
            plt.pause(0.1)
            plt.clf()
    plt.show()
    return lst

print(lst)
print(insertion_sort(lst))
</code>```

So the solution i came up with for this problem was to create a second list containing the current i and i-1 indexes and basically plot a second barchart over the main one set to a different color. Bad solution and failed indeed. Another idea i tried was to pass a conditional argument for the color paramater of plt.bar()

```<code>colors = ['red' if lst[i-1]>lst[i] else for element in lst 'blue']
plt.bar(x, lst, color=colors)
</code>```

This did not work aswell. dont know if am on the right track and just need to keep at it or this is whole setup is futile to begin with. thank you for your time!!

Body:
So im trying to write a sorting algorithm visualizer. Code bellow. I am basically using matplotlib to plot the figure. My problem is that i want to also highlight the current element in the array being accessed, compared, and swaped. all of my attempts have failed at this. Please do also let me know if there is a better way of writing a visulizer in python. I have seen some tutorials using pygame but wanted to stick to basics. Also when the program runs till the end and everthing is sorted the plot goes blank. Is this because of the plt.clf() command and is there a way for the sorted plot to not close. Thanks!!!

from matplotlib import pyplot as plt
import numpy as np

# generate sudo-random list of numbers
lst = np.random.randint(0, 100, 20)

# x values for the bar plot
x = range(0, len(lst))

def insertion_sort(lst):
# loop through the list
# incrementally check which index to the left should i be placed in
    for i in range(1, len(lst)):

        while lst[i-1] > lst[i] and i>0:

            lst[i], lst[i-1] = lst[i-1], lst[i]
            i = i-1

            # plot
            plt.bar(x,lst)
            plt.pause(0.1)
            plt.clf()
    plt.show()
    return lst

print(lst)
print(insertion_sort(lst))

So the solution i came up with for this problem was to create a second list containing the current i and i-1 indexes and basically plot a second barchart over the main one set to a different color. Bad solution and failed indeed. Another idea i tried was to pass a conditional argument for the color paramater of plt.bar()

colors = ['red' if lst[i-1]>lst[i] else for element in lst 'blue']
plt.bar(x, lst, color=colors)

This did not work aswell. dont know if am on the right track and just need to keep at it or this is whole setup is futile to begin with. thank you for your time!!


问:
Why is npm run not working under alpine linux?
I'm trying to run npm run test and npm run server, as defined in my package.json

  "scripts": {
    "server": "app/server.js",
    "build": "npm run test && npm run build server",
    "test": "test/default.js"
  },
```
<p>However, both fail as if <code>npm</code> didn't recognize any syntax. It is worth noting that while <code>app/server.js</code> was generated from ts without any warnings with <code>tsc</code>, and <code>test/default.js</code> was written from scratch in JS.</p>
<pre class="lang-js prettyprint-override"><code>npm run server

> my-project@1.0.0 server
> app/server.js

app/server.js: line 1: use strict: not found
app/server.js: line 2: exports.__esModule: not found
app/server.js: line 3: syntax error: unexpected "("
</code>```
```<code>npm run test
> my-project@1.0.0 test
> test/default.js

test/default.js: line 1: syntax error: unexpected "("
</code>```
```<code>head -n 7 test/default.js

const request = require('supertest');
const chai = require('chai');
const app = require('./server');

const expect = chai.expect;

describe('GET /vehicles/:id', () => {
</code>```
```<code>head -n 10 app/server.js

"use strict";
exports.__esModule = true;
var express_1 = require("express");
var body_parser_1 = require("body-parser");
var pg_1 = require("pg");

// Create a new Express app
var app = (0, express_1["default"])();
// Parse JSON bodies
app.use(body_parser_1["default"].json())
</code>```

I have run npm install with no issues. The linter does not report any issues. I'm running npm 9.2.0 and node 18.12.1. However, the issue also occurs on Manjaro, so it might not be an issue specific to Alpine, but something wrong with my code. In my tsconfig.json I've set it to use es2020.

From my npm config:

```<code>globalignorefile = "/etc/npmignore"
prefix = "/usr/local"
python = "/usr/bin/python3"

ignore-scripts = false
script-shell = "/bin/zsh"
</code>```

I have tried running the whole thing under Docker and on a different machine, so might be an issue with my code. I know require is not natively supported by TypeScript, but the files are JS, so I don't know what's the issue. Sorry if my question sounds stupid, but earlier I've run TypeScript using Deno without the whole hassle of transpiling it to JS and used Node for 'pure' JS only.

Body:
I'm trying to run npm run test and npm run server, as defined in my package.json

  "scripts": {
    "server": "app/server.js",
    "build": "npm run test && npm run build server",
    "test": "test/default.js"
  },

However, both fail as if npm didn't recognize any syntax. It is worth noting that while app/server.js was generated from ts without any warnings with tsc, and test/default.js was written from scratch in JS.

npm run server

> my-project@1.0.0 server
> app/server.js

app/server.js: line 1: use strict: not found
app/server.js: line 2: exports.__esModule: not found
app/server.js: line 3: syntax error: unexpected "("

npm run test
> my-project@1.0.0 test
> test/default.js

test/default.js: line 1: syntax error: unexpected "("

head -n 7 test/default.js

const request = require('supertest');
const chai = require('chai');
const app = require('./server');

const expect = chai.expect;

describe('GET /vehicles/:id', () => {

head -n 10 app/server.js

"use strict";
exports.__esModule = true;
var express_1 = require("express");
var body_parser_1 = require("body-parser");
var pg_1 = require("pg");

// Create a new Express app
var app = (0, express_1["default"])();
// Parse JSON bodies
app.use(body_parser_1["default"].json())

I have run npm install with no issues. The linter does not report any issues. I'm running npm 9.2.0 and node 18.12.1. However, the issue also occurs on Manjaro, so it might not be an issue specific to Alpine, but something wrong with my code. In my tsconfig.json I've set it to use es2020.

From my npm config:

globalignorefile = "/etc/npmignore"
prefix = "/usr/local"
python = "/usr/bin/python3"

ignore-scripts = false
script-shell = "/bin/zsh"

I have tried running the whole thing under Docker and on a different machine, so might be an issue with my code. I know require is not natively supported by TypeScript, but the files are JS, so I don't know what's the issue. Sorry if my question sounds stupid, but earlier I've run TypeScript using Deno without the whole hassle of transpiling it to JS and used Node for 'pure' JS only.


问:
when I tried to run the codes below, it's giving some errors
Trying to create a pos system that develop an application that verify that the right user enters the system, and provide ability for the cashier to perform sales related activities like selling an item, accepting returns, recording sales and updating on-hand inventory, handle payments. etc.

Here are my codes:

Login Verification

X | [a) Assignment

def login():

attempts = 0

user_id = input("Please enter your User ID: ")

password = input("Please enter your password: ")

while attempts < 3:

if user_id == "user" and password ==

"password":

print( Login successful!")

return True else:

attempts += 1 if attempts < 3:

print("Incorrect credentials. Please try again.")

else:

print("Too many attempts. Access denied.")

return False

Create Item Class

class Item:

def init(self, upc, description, item_max_qty, order_threshold, replenishment_order_qty, item_on_hand, unit_price, order_placed):

self.upc = upc

self.description = description

self.item_max_qty = item_max_qty

self.order_threshold = order_threshold

self.replenishment_order_qty = replenishment_order_aty

self.item_on_hand = item_on_ hand

self.unit price = unit price

self.order_placed = order _placed

def updateUnitOnHand(self, numberOfltems):

self.item_on_hand += numberOfltems

Load Inventory Data

login():

file = open("RetailStoreltemData.txt", "r")

inventory = {

for line in file:

upc, description, item_max_qty, order_threshold, replenishment_order_aty, item_on_hand, unit_price, order_placed = line.strip().split("")

item = Item(upc, description, item_max_aty, order_ threshold, replenishment _order_aty, item_on_hand, unit price, order_placed)

inventory[upc] = item

Start a new Sale

def newSale():

sale = {]

while True:

upc = input("Please enter the UPC of the item you'd like to add to your sale. Enter 'done' when finished: ")

if upc.lower == "done":

break

item = inventory upc]

if item.item_on_hand > 0:

item.updateUnitOnHand(-1)

if upc in sale:

sale[upc] += 1 else:

sale[upc] = 1

else:

return sale

print("Sorry, we are currently out of stock on this item.")

X

品

Assignment 7 - Designi

Finalize Sale

def finalizeSale(sale):

total = 0

print("In Your sale:")

for upc in sale:

item = inventory[upc]

price = item.unit_price * sale[upc]

total += price

print (f"(item.description]: {sale [upc]} × {item.unit_price) = (price]")

print (f"Total: {totall\n")

cash = input(Please enter the amount of cash given: ")

if float(cash) >= total:

return True else:

return False

Assic

Handle Returns

def returnltem(sale):

upc = input("Please enter the UPC of the item you'd like to return: ")

if upc in sale:

item = inventory[upc]

item.updateUnitOnHand(1)

sale[upc] -= 1 if sale[upc] == 0:

del sale[upc]

print("Item successfully returned.")

else:

print("This item is not in your sale.")

def returnAllitems (sale):

for upc in sale:

item = inventory [upc]

item.updateUnitOnHand(sale [upc])

sale.clear()

print("All items successfully returned.")

Generate Reports

def generatelnventory Report():

print ("\nINVENTORY REPORTIn")

print (*UPC\DESCRIPTION\MAX QTY\tORDER THRESHOLD\tREPLENISHMENT ORDER QTY\tON HAND\UNIT PRICE\ORDER PLACED\n") for upc in inventory:

item = inventory[upc]

print(f" (item.upc)\t(item.description]\t(item.item_max_qty|\t{item.order_threshold)\t(item.replenishment_order_aty|\titem.item_on_hand/\t{item.unit_price}\t(item.order_placed)")

def generateSalesReport:

print("\nSALES REPORT\n")

print("UPC\tDESCRIPTION\tUNIT PRICE\QTY SOLD\n")

total = 0

for upc in inventory:

item = inventory [upc]

if item.order_placed == "y".

aty_sold = int(item.item_max_qty) - int(item.item_on_hand)

print (fª(item.upc}\t(item.description}\t(item.unit_price|\taty_sold!")

total += aty_sold * float(item.unit price)

print(fIn Total Sales: (total)")

Main Program

An

if login0:

while True:

if option == "1".

sale = newSale()

if finalize.Sale(sale).

option = input("\n. Start a new sale\n2. Generate Inventory Report\n3. Generate Sales Report\n4. Quit\n\nPlease enter an option: ")

if finalizeSale(sale):

print("Thank you for your purchase!")

else:

print("Insufficient funds.")

return item(sale)

elif option == "2".

generate inventory Report()

elif option == "3":

generateSalesReport0

elif option == "4".

break else:

print(Invalid option. Please try again.")

print("\n Thank you for using the POS system. Have a great day!")


问:
How to mount a Windows network dirve to container
I am new to Docker and want to bind an existing network folder of a Windows Server to a container using docker compose. Please help.

I tried below command to created a volume already.

```<code>docker volume create `
--driver local `
--opt type=cifs `
--opt device=\\MyServer\Folder `
--opt o=user=login,domain=my_domain,password=my_passowrd `
MyVolumeName
</code>```

The above command is successfully run, but can't be used in docker compose up command.

How can I use this volume or how to define this volume in docker compose.

Thanks

Body:
I am new to Docker and want to bind an existing network folder of a Windows Server to a container using docker compose. Please help.

I tried below command to created a volume already.

docker volume create `
--driver local `
--opt type=cifs `
--opt device=\\MyServer\Folder `
--opt o=user=login,domain=my_domain,password=my_passowrd `
MyVolumeName

The above command is successfully run, but can't be used in docker compose up command.

How can I use this volume or how to define this volume in docker compose.

Thanks


问:
how to import variables from a json file to attributes in BUILD.bazel?
I would like to import variables defined in a json file(my_info.json) as attibutes for bazel rules.
I tried this (https://docs.bazel.build/versions/5.3.1/skylark/tutorial-sharing-variables.html) and works but do not want  to use a .bzl file and import variables directly to attributes to BUILD.bazel.

I want to use those variables imported from my_info.json as attributes for other BUILD.bazel files.

projects/python_web/BUILD.bazel

```<code>load("//projects/tools/parser:config.bzl", "MY_REPO","MY_IMAGE")
container_push(
  name = "publish",
  format = "Docker",
  registry = "registry.hub.docker.com",
  repository = MY_REPO,
  image = MY_IMAGE,
  tag = "1",
)
</code>```

Asking the similar in Bazel slack I was informed the is not possible to import variables directly to  Bazel and it is needed to parse the json variables and write them into a .bzl file.

I tried also this code but nothing is written in config.bzl file.

my_info.json

```<code>{
    "MYREPO" : "registry.hub.docker.com",
    "MYIMAGE" : "michael/monorepo-python-web"
}
</code>```

WORKSPACE.bazel

```<code>load("//projects/tools/parser:jsonparser.bzl", "load_my_json")
load_my_json(
    name = "myjson"
)
</code>```

projects/tools/parser/jsonparser.bzl

```<code>def _load_my_json_impl(repository_ctx):
    json_data = json.decode(repository_ctx.read(repository_ctx.path(Label(":my_info.json"))))
    config_lines = ["%s = %s" % (key, repr(val)) for key, val in json_data.items()]
    repository_ctx.file("config.bzl", "\n".join(config_lines))

load_my_json = repository_rule(
    implementation = _load_my_json_impl,
    attrs = {},
)
</code>```

projects/tools/parser/BUILD.bazel

```<code>load("@aspect_bazel_lib//lib:yq.bzl", "yq")
load(":config.bzl", "MYREPO", "MY_IMAGE")

yq(
    name = "convert",
    srcs = ["my_info2.json"],
    args = ["-P"],
    outs = ["bar.yaml"],
)
</code>```

Executing:
% bazel build projects/tools/parser:convert

```<code>ERROR: Traceback (most recent call last):
        File "/Users/michael.taquia/Documents/Personal/Projects/bazel/bazel-projects/multi-language-bazel-monorepo/projects/tools/parser/BUILD.bazel", line 2, column 22, in <toplevel>
                load(":config.bzl", "MYREPO", "MY_IMAGE")
Error: file ':config.bzl' does not contain symbol 'MYREPO'
</code>```

When making troubleshooting I see the execution calls the jsonparser.bzl but never enters to _load_my_json_impl function (based in print statements) and does not write anything to config.bzl.

Notes: Tested on macOS 12.6 (21G115 ) Darwin Kernel Version 21.6.0

```<code>There is a better way to do that? A code snippet will be very useful.

</code>```

Body:
I would like to import variables defined in a json file(my_info.json) as attibutes for bazel rules.
I tried this (https://docs.bazel.build/versions/5.3.1/skylark/tutorial-sharing-variables.html) and works but do not want  to use a .bzl file and import variables directly to attributes to BUILD.bazel.

I want to use those variables imported from my_info.json as attributes for other BUILD.bazel files.

projects/python_web/BUILD.bazel

load("//projects/tools/parser:config.bzl", "MY_REPO","MY_IMAGE")
container_push(
  name = "publish",
  format = "Docker",
  registry = "registry.hub.docker.com",
  repository = MY_REPO,
  image = MY_IMAGE,
  tag = "1",
)

Asking the similar in Bazel slack I was informed the is not possible to import variables directly to  Bazel and it is needed to parse the json variables and write them into a .bzl file.

I tried also this code but nothing is written in config.bzl file.

my_info.json

{
    "MYREPO" : "registry.hub.docker.com",
    "MYIMAGE" : "michael/monorepo-python-web"
}

WORKSPACE.bazel

load("//projects/tools/parser:jsonparser.bzl", "load_my_json")
load_my_json(
    name = "myjson"
)

projects/tools/parser/jsonparser.bzl

def _load_my_json_impl(repository_ctx):
    json_data = json.decode(repository_ctx.read(repository_ctx.path(Label(":my_info.json"))))
    config_lines = ["%s = %s" % (key, repr(val)) for key, val in json_data.items()]
    repository_ctx.file("config.bzl", "\n".join(config_lines))

load_my_json = repository_rule(
    implementation = _load_my_json_impl,
    attrs = {},
)

projects/tools/parser/BUILD.bazel

load("@aspect_bazel_lib//lib:yq.bzl", "yq")
load(":config.bzl", "MYREPO", "MY_IMAGE")

yq(
    name = "convert",
    srcs = ["my_info2.json"],
    args = ["-P"],
    outs = ["bar.yaml"],
)

Executing:
% bazel build projects/tools/parser:convert

ERROR: Traceback (most recent call last):
        File "/Users/michael.taquia/Documents/Personal/Projects/bazel/bazel-projects/multi-language-bazel-monorepo/projects/tools/parser/BUILD.bazel", line 2, column 22, in <toplevel>
                load(":config.bzl", "MYREPO", "MY_IMAGE")
Error: file ':config.bzl' does not contain symbol 'MYREPO'

When making troubleshooting I see the execution calls the jsonparser.bzl but never enters to _load_my_json_impl function (based in print statements) and does not write anything to config.bzl.

Notes: Tested on macOS 12.6 (21G115 ) Darwin Kernel Version 21.6.0

There is a better way to do that? A code snippet will be very useful.


问:
Store database name in a variable and use it in Sql Server

Possible Duplicate:

  How to use variable for database name in t-sql

If I do Select * from Production.dbo.MatchTable it works.(where Production is database name)

Now I need to use it in a variable first as

```<code>Declare @dbName As varchar(20) = 'Test'
</code>```

And then if I do Select * from @dbName.dbo.MatchTable I get an error

Msg 102, Level 15, State 1, Line 5 Incorrect syntax near '.'.

Then how can I use it.

The reason is that, at the time of testing we will change the db name. So changing the same in many places in many store procs will be an issue.

Also I cannot write a dynamic query.

So what may be the way of doing it? Synonyms won't work as it is not applicable for database name.

Thanks

ContentLicense: CC BY-SA 3.0

Body:
Possible Duplicate:

  How to use variable for database name in t-sql

If I do Select * from Production.dbo.MatchTable it works.(where Production is database name)

Now I need to use it in a variable first as

Declare @dbName As varchar(20) = 'Test'

And then if I do Select * from @dbName.dbo.MatchTable I get an error

Msg 102, Level 15, State 1, Line 5 Incorrect syntax near '.'.

Then how can I use it.

The reason is that, at the time of testing we will change the db name. So changing the same in many places in many store procs will be an issue.

Also I cannot write a dynamic query.

So what may be the way of doing it? Synonyms won't work as it is not applicable for database name.

Thanks


问:
Web scrap dropdonw witout options
I need web scraper dropdonw of this web site https://citascuba.sre.gob.mx/registro-cuenta</p>

Title: Web scrap dropdonw witout options


问:
How do I remove the arrow on my Github directory and make it clickable?
This is the directory on Github:
(https://i.stack.imgur.com/HV2Fi.png)

I started this by starting a React Native app inside an existing Github repository.

Deleting the hidden .git file in said directory Portfolio and clearing cache from parent directory didn't resolve.

If it helps your direction, I have only one branch and do not want any more, if possible.

Various sources tell me I accidentally created a nested repository.

Command  git config -l shows Portfolio is still a submodule. If I need to turn this submodule into a regular directory, please also share how to do that because I have exhausted other resources.

Please and thank you your direction!


问:
Next.js build time using getStaticProps for high amount of dynamic routes
I have been looking into using Next.js for an E-commerce application, and wanted to find out if using Static Generation would cause an issue regarding build time if I wanted to getStaticProps for every product.

If we have hundreds of products, with each product page in its own dynamic route, would the build command run hundreds of requests to build the first cached version of each page?

Our API with product data can be slow at times, and I am wondering if this would cause long build times following this approach.

Thank you

I have run an ISR build on one of my pages (though not a product page) and this alone took 5 seconds. message on terminal (https://imgur.com/a/h6KSgW4)


问:
Mongodb kafka connector is running but the data is not getting published in sink cluster
I was using mongodb kafka connector on confluent cloud and the data source and sink cluster was in mongodb. Although the connectors on confluent cloud is running, the source connector on confluent shows the spike as well as count of message processed each time when the data is being inserted in source cluster, the data is not getting published in the sink cluster (source and sink cluster belongs to two different account of mongodb).. Can somebody tell me why is it not able to transmit the data.

As both the connectors are connected successfully and they are up and running ,I was expecting that data which is being added to mongodb source cluster, it should get reflected in sink cluster.


问:
Why does chromiuim trigger DRM (Direct Rendering Manager) on startup on Linux?
I was wondering if anyone knows why chromium based browsers trigger direct rendering manager on startup on Linux whereas Firefox for example doesn't seem to do that? This is what I see when starting chromium:</p>
```<code>Dec 19 11:02:30 hp kernel: [drm] PCIE GART of 256M enabled (table at 0x000000F400000000).
Dec 19 11:02:31 hp kernel: [drm] UVD and UVD ENC initialized successfully.
Dec 19 11:02:31 hp kernel: [drm] VCE initialized successfully.
</code>```

Body:
I was wondering if anyone knows why chromium based browsers trigger direct rendering manager on startup on Linux whereas Firefox for example doesn't seem to do that? This is what I see when starting chromium:

Dec 19 11:02:30 hp kernel: [drm] PCIE GART of 256M enabled (table at 0x000000F400000000).
Dec 19 11:02:31 hp kernel: [drm] UVD and UVD ENC initialized successfully.
Dec 19 11:02:31 hp kernel: [drm] VCE initialized successfully.


问:
Android13 Permission denied while picking images
after android13 release my application got a problem with picking image it show permission denied while picking image.

On androidMinifest.xml

```<code>    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
</code>```

Flutter 1.17

Image_picker:
multiple_image_picker:

Error capture image is above.

Body:
after android13 release my application got a problem with picking image it show permission denied while picking image.

On androidMinifest.xml

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

Flutter 1.17

Image_picker:
multiple_image_picker:

Error capture image is above.


问:
How Do I Close The Hamburger Menu When Navigating Back And Forth Between Web Pages?
I've got some Javascript running on my website (the works really well) that enables my menu to close the hamburger menu after a link in it has been clicked.

```<code>    var elements = document.getElementsByTagName('li');
var closeHamp = function() {
 document.getElementsByClassName('cp_menuicon')[0].click();
    };

　for (var i = 0; i < elements.length; i++) {
　　elements[i].addEventListener('click', closeHamp, false);
    }
</code>```

I'd like to set up the hamburger menu so that it will also close automatically when navigating back and forth (using the back and forward buttons). Would this involve using this if(performance.getEntriesByType("navigation")[0].type == "back_forward") script? Any knowledge that you could share with me on how to achieve this would be very much appreciated.

The code for my menu:

```<code><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;">

<li style="border-bottom: 1px solid lightgray;"><a href="#">Home</a></li>
<li style="border-bottom: 1px solid lightgray;"><a href="#">Blog</a></li>
<li style="border-bottom: 1px solid lightgray;"><a href="#">About This Website</a></li>
<li style="border-bottom: 1px solid lightgray;"><a href="#">Bibliography</a></li>
</code>```

The CSS:

```<code> .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%;
            margin-bottom: -40px;
        }

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

.site-footer,
.page-wrap:after {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;
            }
        }
</code>```

Body:
I've got some Javascript running on my website (the works really well) that enables my menu to close the hamburger menu after a link in it has been clicked.

    var elements = document.getElementsByTagName('li');
var closeHamp = function() {
 document.getElementsByClassName('cp_menuicon')[0].click();
    };

　for (var i = 0; i < elements.length; i++) {
　　elements[i].addEventListener('click', closeHamp, false);
    }

I'd like to set up the hamburger menu so that it will also close automatically when navigating back and forth (using the back and forward buttons). Would this involve using this if(performance.getEntriesByType("navigation")[0].type == "back_forward") script? Any knowledge that you could share with me on how to achieve this would be very much appreciated.

The code for my menu:

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

Home

Blog

About This Website

Bibliography

The CSS:

 .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%;
            margin-bottom: -40px;
        }

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

.site-footer,
.page-wrap:after {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;
            }
        }


问:
Responsive `slide toggle` to slide from the bottom in website for mobile
I have a function slide toggle slides from right to left to show information in my webside. It works fine on windows but when I open my website on mobile my slide toggle covers the whole website screen. How can I change the slide toggle to slide from the bottom and be responsive for mobile interface or less than 750px.

This is my code for slide toggle:

var easing = 1;
var animation_speed = 200;
var slider_width;
var is_collapsed = true;

function slideToggle() {
  is_collapsed = $('#btn').css("margin-right") == slider_width + "px" && !$('#btn').is(':animated');
  var sign = (is_collapsed) ? '-' : '+';
  if (!$('#btn').is(':animated')) {
    if (easing) $('.willSlide').animate({
      "margin-right": sign + '=' + slider_width
    }, animation_speed);
    else $('.willSlide').animate({
      "margin-right": sign + '=' + slider_width
    }, animation_speed);
  }
  (is_collapsed) ? $('.willSlide').removeClass('expanded'): $('.willSlide').addClass('expanded');
}

//function to open slide
function slideOpen() {
  //if is_collapsed is true, animate div and open slider
  if (is_collapsed) {
    var sign = '+'
    $('.willSlide').animate({
      "margin-right": sign + '=' + slider_width
    }, animation_speed);
    //add expanded class to button when opened
    $('.willSlide').addClass('expanded')
    //set is_collapsed to false so it won't close slider on additional clicks
    is_collapsed = false
  }
}

$(document).ready(function() {
  slider_width = $('#content').width(); //get width automaticly
  $('#btn').click(slideToggle);
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>#content {
  position: fixed;
  height: 100%;
  background: rgb(97, 97, 97);
  width: 450px;
  right: 0px;
  margin-right: -450px;
}

#btn {
  position: fixed;
  width: 100px;
  right: 0px;
  background: rgb(117, 231, 117);
  top: 100px;
  border-radius: 5px 0px 0 5px;
  color: #fff;
  text-align: center;
  padding: 40px 0;
  cursor: pointer
}

.expandedTxt {
  display: none
}

#btn.expanded .expandedTxt {
  display: block
}

#btn.expanded .click {
  display: none
}</code>```

  open
  close

```

Here is demo for slide toggle

Body:
I have a function slide toggle slides from right to left to show information in my webside. It works fine on windows but when I open my website on mobile my slide toggle covers the whole website screen. How can I change the slide toggle to slide from the bottom and be responsive for mobile interface or less than 750px.

This is my code for slide toggle:

var easing = 1;
var animation_speed = 200;
var slider_width;
var is_collapsed = true;

function slideToggle() {
  is_collapsed = $('#btn').css("margin-right") == slider_width + "px" && !$('#btn').is(':animated');
  var sign = (is_collapsed) ? '-' : '+';
  if (!$('#btn').is(':animated')) {
    if (easing) $('.willSlide').animate({
      "margin-right": sign + '=' + slider_width
    }, animation_speed);
    else $('.willSlide').animate({
      "margin-right": sign + '=' + slider_width
    }, animation_speed);
  }
  (is_collapsed) ? $('.willSlide').removeClass('expanded'): $('.willSlide').addClass('expanded');
}

//function to open slide
function slideOpen() {
  //if is_collapsed is true, animate div and open slider
  if (is_collapsed) {
    var sign = '+'
    $('.willSlide').animate({
      "margin-right": sign + '=' + slider_width
    }, animation_speed);
    //add expanded class to button when opened
    $('.willSlide').addClass('expanded')
    //set is_collapsed to false so it won't close slider on additional clicks
    is_collapsed = false
  }
}

$(document).ready(function() {
  slider_width = $('#content').width(); //get width automaticly
  $('#btn').click(slideToggle);
});

#content {
  position: fixed;
  height: 100%;
  background: rgb(97, 97, 97);
  width: 450px;
  right: 0px;
  margin-right: -450px;
}

#btn {
  position: fixed;
  width: 100px;
  right: 0px;
  background: rgb(117, 231, 117);
  top: 100px;
  border-radius: 5px 0px 0 5px;
  color: #fff;
  text-align: center;
  padding: 40px 0;
  cursor: pointer
}

.expandedTxt {
  display: none
}

#btn.expanded .expandedTxt {
  display: block
}

#btn.expanded .click {
  display: none
}

  open
  close

Here is demo for slide toggle


问:
Meaning of an exclamation mark in classpath files under project structure in IDEA
While going through the project structure in IntelliJ IDEA Ultimate 2022.3, I saw these (highlighted ones):

I'm not sure about the meaning of exclamation marks here.


问:
Recomputing a struct for a quiz game
I am very new to Swift (I started 5 days ago), and I am working on my first app. I'm almost finished with it. It lets you listen to chords, and you can take a quiz to test your relative pitch ability. However, the quiz only works once, because when the quiz ends, it retains the same questions, and my index variable for the questions goes out of range. Thus I decided to make a function that resets the Answers that can be called by my QuizViewModel after the quiz is finished. However, I'm having some trouble figuring out the logic. I made a function in my Answer model, but it doesn't seem to carry over to my Quiz Model. Here are the models in question:

Answer model

```<code>import Foundation

let roots = ["A", "B", "C", "D", "E", "F", "G"]
let chordType = ["Major", "Minor"]

func chooseChord() -> String {
    let randomRoot = roots.randomElement()!
    let randomType = chordType.randomElement()!
    let randomChord = randomRoot + randomType
    return randomChord
}

func genAnswer() -> (String, [String]) {
    var answers = [String]()
    while answers.count < 4 {
        let randChord = chooseChord()
        if !answers.contains(randChord) {
            answers.append(randChord)
        }
    }
    let correctAnswer = answers.randomElement()!
    return (correctAnswer, answers)
}

struct Answer {
    private var correctAnswer: String
    private var possibleAnswers: [String]

    func getCorrectAnswer() -> String {
        return correctAnswer
    }

    func getPossibleAnswers() -> [String] {
        return possibleAnswers
    }

    init() {
        let answer = genAnswer()
        self.correctAnswer = answer.0
        self.possibleAnswers = answer.1
    }

    static var allAnswers: [Answer] = [
        Answer(),
        Answer(),
        Answer(),
        Answer(),
        Answer()
    ]

    func resetAnswers() {
        var newAnswers = [Answer]()
        for _ in 1...Answer.allAnswers.count {
            let new = Answer.init()
            newAnswers.append(new)
        }
        Answer.allAnswers = newAnswers
    }
}
</code>```

Quiz model

```<code>import Foundation

class Quiz {
    private var rounds = Answer.allAnswers
    private var currentRoundIndex = 0

    var currentRound: Answer {
        return rounds[currentRoundIndex]
    }

    var totalRounds: Int {
        rounds.count - 1
    }

    func advanceRound() {
        let nextRoundIndex = currentRoundIndex + 1
        currentRoundIndex = nextRoundIndex
    }

    func reset() {
        Answer.resetAnswers()
        currentRoundIndex = 0
    }
</code>```

QuizViewModel

```<code>import Foundation

class QuizViewModel: ObservableObject {
    @Published var game = Quiz()

    var correctAnswerText: String {
        game.currentRound.getCorrectAnswer()
    }

    func answerText() -> [String] {
        game.currentRound.getPossibleAnswers()
    }

    var totalRounds: Int {
        return game.totalRounds
    }

    func advanceGame() {
        game.advanceRound()
    }
}

</code>```

Here is the full Git repo if you are interested: https://github.com/aabagdi/Chord-Helper

Thanks for your help!

Title: Recomputing a struct for a quiz game

Body:
I am very new to Swift (I started 5 days ago), and I am working on my first app. I'm almost finished with it. It lets you listen to chords, and you can take a quiz to test your relative pitch ability. However, the quiz only works once, because when the quiz ends, it retains the same questions, and my index variable for the questions goes out of range. Thus I decided to make a function that resets the Answers that can be called by my QuizViewModel after the quiz is finished. However, I'm having some trouble figuring out the logic. I made a function in my Answer model, but it doesn't seem to carry over to my Quiz Model. Here are the models in question:

Answer model

import Foundation

let roots = ["A", "B", "C", "D", "E", "F", "G"]
let chordType = ["Major", "Minor"]

func chooseChord() -> String {
    let randomRoot = roots.randomElement()!
    let randomType = chordType.randomElement()!
    let randomChord = randomRoot + randomType
    return randomChord
}

func genAnswer() -> (String, [String]) {
    var answers = [String]()
    while answers.count < 4 {
        let randChord = chooseChord()
        if !answers.contains(randChord) {
            answers.append(randChord)
        }
    }
    let correctAnswer = answers.randomElement()!
    return (correctAnswer, answers)
}

struct Answer {
    private var correctAnswer: String
    private var possibleAnswers: [String]

    func getCorrectAnswer() -> String {
        return correctAnswer
    }

    func getPossibleAnswers() -> [String] {
        return possibleAnswers
    }

    init() {
        let answer = genAnswer()
        self.correctAnswer = answer.0
        self.possibleAnswers = answer.1
    }

    static var allAnswers: [Answer] = [
        Answer(),
        Answer(),
        Answer(),
        Answer(),
        Answer()
    ]

    func resetAnswers() {
        var newAnswers = [Answer]()
        for _ in 1...Answer.allAnswers.count {
            let new = Answer.init()
            newAnswers.append(new)
        }
        Answer.allAnswers = newAnswers
    }
}

Quiz model

import Foundation

class Quiz {
    private var rounds = Answer.allAnswers
    private var currentRoundIndex = 0

    var currentRound: Answer {
        return rounds[currentRoundIndex]
    }

    var totalRounds: Int {
        rounds.count - 1
    }

    func advanceRound() {
        let nextRoundIndex = currentRoundIndex + 1
        currentRoundIndex = nextRoundIndex
    }

    func reset() {
        Answer.resetAnswers()
        currentRoundIndex = 0
    }

QuizViewModel

import Foundation

class QuizViewModel: ObservableObject {
    @Published var game = Quiz()

    var correctAnswerText: String {
        game.currentRound.getCorrectAnswer()
    }

    func answerText() -> [String] {
        game.currentRound.getPossibleAnswers()
    }

    var totalRounds: Int {
        return game.totalRounds
    }

    func advanceGame() {
        game.advanceRound()
    }
}

Here is the full Git repo if you are interested: https://github.com/aabagdi/Chord-Helper

Thanks for your help!


问:
How to associate a JVM argument with an Ant task?
Currently, I have an Ant task that I invoke like this:

```<code>ant -f build-direct.xml email -Dmail.smtp.ssl.protocols=TLSv1.2
</code>```

This is the email task:

```<code><target name="email" depends="init" unless="email.skip">
    <condition property="build.version.stableStatus" value="stable" else="non-stable">
        <or>
            <matches string="${build.version.tag}" pattern="^GA$"/>
            <matches string="${build.version.tag}" pattern="^GA-E[0-9]{2}$"/>
        </or>
    </condition>
    <echo message="is stable: ${build.version.stableStatus}"/>
    <mail mailhost="${email.host}" mailport="${email.port}" ssl="${email.ssl}" user="${email.smtp.user}" password="${email.smtp.password}"
          replyto="${email.from}" from="${email.from}" tolist="${email.to}" cclist="${email.cc}"
          subject="The ${build.version} build has completed">
        <message>email body here</message>
    </mail>
</target>
</code>```

I would like to simplify this command by permanently associating the argument -Dmail.smtp.ssl.protocols=TLSv1.2 with this email task. I read about the <jvmarg> tag but I am not sure how to apply it. Can someone guide me on how to do this? Thanks!

Body:
Currently, I have an Ant task that I invoke like this:

ant -f build-direct.xml email -Dmail.smtp.ssl.protocols=TLSv1.2

This is the email task:

<target name="email" depends="init" unless="email.skip">
    <condition property="build.version.stableStatus" value="stable" else="non-stable">
        <or>
            <matches string="${build.version.tag}" pattern="^GA$"/>
            <matches string="${build.version.tag}" pattern="^GA-E[0-9]{2}$"/>
        </or>
    </condition>
    <echo message="is stable: ${build.version.stableStatus}"/>
    <mail mailhost="${email.host}" mailport="${email.port}" ssl="${email.ssl}" user="${email.smtp.user}" password="${email.smtp.password}"
          replyto="${email.from}" from="${email.from}" tolist="${email.to}" cclist="${email.cc}"
          subject="The ${build.version} build has completed">
        <message>email body here</message>
    </mail>
</target>

I would like to simplify this command by permanently associating the argument -Dmail.smtp.ssl.protocols=TLSv1.2 with this email task. I read about the <jvmarg> tag but I am not sure how to apply it. Can someone guide me on how to do this? Thanks!


问:
how to allow http repo in maven wrapper
My project use maven wrapper

```<code>$ ./mvnw -v
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /home/xxx/.m2/wrapper/dists/apache-maven-3.8.6-bin/67568434/apache-maven-3.8.6
Java version: 1.8.0_332, vendor: Temurin, runtime: /home/xxx/.jdks/temurin-1.8.0/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.19.0-26-generic", arch: "amd64", family: "unix"
</code>```

but when I type ./mvnw package,I got

Failed to execute goal on project insight-scheduler: Could not resolve dependencies for project io.xxx:insight-s:jar:1.0-SNAPSHOT: Failed to collect dependencies at io.xxx.g:g-client:jar:2.0: Failed to read artifact descriptor for io.xxx.g:g-client:jar:2.0: Could not transfer artifact io.xxx.g:g-client:pom:2.0 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [priv-xxx-libs-release

How do I

I first thought it was a private repository authentication problem, but then I found this is the new version of maven does not allow http by default, you can configure it inside settings.xml, but I used the maven wrapper, this configuration did not take effect.
What do I need to do

Title: how to allow http repo in maven wrapper

Body:
My project use maven wrapper

$ ./mvnw -v
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /home/xxx/.m2/wrapper/dists/apache-maven-3.8.6-bin/67568434/apache-maven-3.8.6
Java version: 1.8.0_332, vendor: Temurin, runtime: /home/xxx/.jdks/temurin-1.8.0/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.19.0-26-generic", arch: "amd64", family: "unix"

but when I type ./mvnw package,I got

Failed to execute goal on project insight-scheduler: Could not resolve dependencies for project io.xxx:insight-s:jar:1.0-SNAPSHOT: Failed to collect dependencies at io.xxx.g:g-client:jar:2.0: Failed to read artifact descriptor for io.xxx.g:g-client:jar:2.0: Could not transfer artifact io.xxx.g:g-client:pom:2.0 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [priv-xxx-libs-release

How do I

I first thought it was a private repository authentication problem, but then I found this is the new version of maven does not allow http by default, you can configure it inside settings.xml, but I used the maven wrapper, this configuration did not take effect.
What do I need to do


问:
How to sync files open between computers using the portable edition?
I have installed the portable edition of vscode on a mega sync folder, and I'm accessing this folder on two different computers that have the same pc/user names, and in both pc vscode is located in the exact same directory:

```<code>D:\MEGAsync\vscode
</code>```

All files open in the editor are accessible and exist on both computers, for example:

D:\MEGAsync\a.txt, D:\MEGAsync\b.txt, etc.

However, when I save/close the workspace in the first computer and open it on the second computer it doesn't contain any of the files I was working on...

In the docs of the portable edition, it says all files exist in the same directory in the folder data, what i'm missing?

Body:
I have installed the portable edition of vscode on a mega sync folder, and I'm accessing this folder on two different computers that have the same pc/user names, and in both pc vscode is located in the exact same directory:

D:\MEGAsync\vscode

All files open in the editor are accessible and exist on both computers, for example:

D:\MEGAsync\a.txt, D:\MEGAsync\b.txt, etc.

However, when I save/close the workspace in the first computer and open it on the second computer it doesn't contain any of the files I was working on...

In the docs of the portable edition, it says all files exist in the same directory in the folder data, what i'm missing?


问:
dht11 sensor timed out with cc2650 launchpad
I'm running launchxl-cc2650 on Contiki to read temperature and humidity value from dht11 sensor. Build with Contiki, and flash with ti programmer 2. But my board can't seem to read the value of the sensor (output reading timed out) i'm trying on 2 difference board and 2 sensors (same type) so i'm pretty sure the problem didn't come from hardware, and the led from sensor light up which mean it has power. This code has been run successfully by my senior last year. so it really confuse me of which could cause the problem, the plug the data to IOID_0 Pin. The code could be found at contiki-ng/dht11.c at develop branch in https://github.com/contiki-ng/contiki-ng with a little twist i made, code be written below.

```<code>#include "contiki.h"
#include <stdio.h>
#include "board.h"
#include "dht11-sensor.h"
/*---------------------------------------------------------------------------*/

PROCESS(dht11_process, "DHT 11 process");
AUTOSTART_PROCESSES(&dht11_process);
/*---------------------------------------------------------------------------*/

#define DHT11_GPIO_PORT (1)
#define DHT11_GPIO_PIN  (12)
#define BOARD_IOID_DIO0           IOID_0
/*---------------------------------------------------------------------------*/

PROCESS_THREAD(dht11_process, ev, data)
{
  static struct etimer timer;
  PROCESS_BEGIN();
  dht11_sensor.configure(DHT11_CONFIGURE_GPIO_PIN, IOID_0);
  dht11_sensor.configure(SENSORS_HW_INIT, 0);

  /* Wait one second for the DHT11 sensor to be ready */
  etimer_set(&timer, CLOCK_SECOND * 1);

  /* Wait for the periodic timer to expire */
  PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));

  /* Setup a periodic timer that expires after 5 seconds. */
  etimer_set(&timer, CLOCK_SECOND * 2);
  while(1) {

    /*
     * Request a fresh read
     */

    SENSORS_ACTIVATE(dht11_sensor);

    switch(dht11_sensor.status(0)) {
        case DHT11_STATUS_OKAY:
             printf("Do Am : %d.%d %% \n",
             dht11_sensor.value(DHT11_VALUE_HUMIDITY_INTEGER),
             dht11_sensor.value(DHT11_VALUE_HUMIDITY_DECIMAL));
             printf("Nhiet Do : %d.%d *C\n",
             dht11_sensor.value(DHT11_VALUE_TEMPERATURE_INTEGER),
             dht11_sensor.value(DHT11_VALUE_TEMPERATURE_DECIMAL));
             break;

        case DHT11_STATUS_CHECKSUM_FAILED:
             printf("Check sum failed\n");
             break;

        case DHT11_STATUS_TIMEOUT:
             printf("Reading timed out\n");
             break;

        default:
             break;
    }

    /* Wait for the periodic timer to expire and then restart the timer. */

    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
    etimer_reset(&timer);
  }

  PROCESS_END();
`
</code>```

The only different thing from my senior is that when i build using make command, it only result in .elf file, not the .hex and .bin file. Could this be the problem? i think it's unlikely cause Ti Programmer 2 support .elf file, and i have been flashing succesfully with .elf file with other examples. Plese lend me your though.

Body:
I'm running launchxl-cc2650 on Contiki to read temperature and humidity value from dht11 sensor. Build with Contiki, and flash with ti programmer 2. But my board can't seem to read the value of the sensor (output reading timed out) i'm trying on 2 difference board and 2 sensors (same type) so i'm pretty sure the problem didn't come from hardware, and the led from sensor light up which mean it has power. This code has been run successfully by my senior last year. so it really confuse me of which could cause the problem, the plug the data to IOID_0 Pin. The code could be found at contiki-ng/dht11.c at develop branch in https://github.com/contiki-ng/contiki-ng with a little twist i made, code be written below.

#include "contiki.h"
#include <stdio.h>
#include "board.h"
#include "dht11-sensor.h"
/*---------------------------------------------------------------------------*/

PROCESS(dht11_process, "DHT 11 process");
AUTOSTART_PROCESSES(&dht11_process);
/*---------------------------------------------------------------------------*/

#define DHT11_GPIO_PORT (1)
#define DHT11_GPIO_PIN  (12)
#define BOARD_IOID_DIO0           IOID_0
/*---------------------------------------------------------------------------*/

PROCESS_THREAD(dht11_process, ev, data)
{
  static struct etimer timer;
  PROCESS_BEGIN();
  dht11_sensor.configure(DHT11_CONFIGURE_GPIO_PIN, IOID_0);
  dht11_sensor.configure(SENSORS_HW_INIT, 0);

  /* Wait one second for the DHT11 sensor to be ready */
  etimer_set(&timer, CLOCK_SECOND * 1);

  /* Wait for the periodic timer to expire */
  PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));

  /* Setup a periodic timer that expires after 5 seconds. */
  etimer_set(&timer, CLOCK_SECOND * 2);
  while(1) {

    /*
     * Request a fresh read
     */

    SENSORS_ACTIVATE(dht11_sensor);

    switch(dht11_sensor.status(0)) {
        case DHT11_STATUS_OKAY:
             printf("Do Am : %d.%d %% \n",
             dht11_sensor.value(DHT11_VALUE_HUMIDITY_INTEGER),
             dht11_sensor.value(DHT11_VALUE_HUMIDITY_DECIMAL));
             printf("Nhiet Do : %d.%d *C\n",
             dht11_sensor.value(DHT11_VALUE_TEMPERATURE_INTEGER),
             dht11_sensor.value(DHT11_VALUE_TEMPERATURE_DECIMAL));
             break;

        case DHT11_STATUS_CHECKSUM_FAILED:
             printf("Check sum failed\n");
             break;

        case DHT11_STATUS_TIMEOUT:
             printf("Reading timed out\n");
             break;

        default:
             break;
    }

    /* Wait for the periodic timer to expire and then restart the timer. */

    PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
    etimer_reset(&timer);
  }

  PROCESS_END();
`

The only different thing from my senior is that when i build using make command, it only result in .elf file, not the .hex and .bin file. Could this be the problem? i think it's unlikely cause Ti Programmer 2 support .elf file, and i have been flashing succesfully with .elf file with other examples. Plese lend me your though.


问:
EKS console / terminal
If I have cluster already setup in AWS EKS, is there a way to access the terminal and run the basic commands like k get pods / services etc. to get familiar with Kubernetes.

My doubt - Is the terminal accessible from within the AWS console itself, not from local machine / laptop terminal/command prompt connecting to AWS account.

Title: EKS console / terminal


问:
Module '"firebase/app"' has no exported member 'auth'
I'm trying to connect to firebase to do Google authentication on the app.

But when I try to do:

```<code>import { auth } from 'firebase/app';
</code>```

I get weird error:

Module '"firebase/app"' has no exported member 'auth'.

I would love to call GoogleAuthProvider method on auth property.

Thank you so much for your help!

I experimented with packages but nothing helped :(

Body:
I'm trying to connect to firebase to do Google authentication on the app.

But when I try to do:

import { auth } from 'firebase/app';

I get weird error:

Module '"firebase/app"' has no exported member 'auth'.

I would love to call GoogleAuthProvider method on auth property.

Thank you so much for your help!

I experimented with packages but nothing helped :(


问:
Subfolder items continue to be created when using ItemClicked() in TreeWidget
The TreeModel creation of the drive was successful using TreeWidget. However, when I clicked on a folder, the children of that folder kept being created, and I tried many times to prevent it, but it kept failing.

```<code>connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &QtWidgetsApplication1::Addtree);

void QtWidgetsApplication1::Addtree(QTreeWidgetItem *root4, int column)
{
    QDir* rootDir = new QDir(root4->text(2));
    QDir test(root4->text(2));
    QFileInfoList filesList = rootDir->entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);

    foreach(QFileInfo fileInfo, filesList)
    {

        QTreeWidgetItem* child = new QTreeWidgetItem();
        child->setText(0, fileInfo.fileName());

        if (fileInfo.isDir())
        {
            QIcon BasicIcon = mpIconProvider->icon(fileInfo);
            child->setIcon(0, BasicIcon);
            child->setText(2, fileInfo.filePath());
            //child->setCheckState(1, Qt::Checked);
        }
        root4->addChild(child);
        ui->treeWidget->addTopLevelItem(root4);
    }
}
</code>```

The code associated with itemClicked to create a child folder is as follows, and I'm not sure how to add it here to limit it to create it once.

Body:
The TreeModel creation of the drive was successful using TreeWidget. However, when I clicked on a folder, the children of that folder kept being created, and I tried many times to prevent it, but it kept failing.

connect(ui->treeWidget, &QTreeWidget::itemClicked, this, &QtWidgetsApplication1::Addtree);

void QtWidgetsApplication1::Addtree(QTreeWidgetItem *root4, int column)
{
    QDir* rootDir = new QDir(root4->text(2));
    QDir test(root4->text(2));
    QFileInfoList filesList = rootDir->entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);

    foreach(QFileInfo fileInfo, filesList)
    {

        QTreeWidgetItem* child = new QTreeWidgetItem();
        child->setText(0, fileInfo.fileName());

        if (fileInfo.isDir())
        {
            QIcon BasicIcon = mpIconProvider->icon(fileInfo);
            child->setIcon(0, BasicIcon);
            child->setText(2, fileInfo.filePath());
            //child->setCheckState(1, Qt::Checked);
        }
        root4->addChild(child);
        ui->treeWidget->addTopLevelItem(root4);
    }
}

The code associated with itemClicked to create a child folder is as follows, and I'm not sure how to add it here to limit it to create it once.


问:
C# Azure Function Limits 250 MB Response Size; I need 2GB response
All the theory around C# azure function app says no size limitation on response. But practically it limits to 250 MB. Anything more than that produces 0 byte response; no error anywhere. My use case is to return ~2GB response. Here's the production app service plan that I'm using. Do I need to configure anything to increase from 250 MB of the size limitation?

```<code>foreach(var outputData in outputList)
    await httpResponseData.Body.WriteAsync(outputData);
</code>```

Body:
All the theory around C# azure function app says no size limitation on response. But practically it limits to 250 MB. Anything more than that produces 0 byte response; no error anywhere. My use case is to return ~2GB response. Here's the production app service plan that I'm using. Do I need to configure anything to increase from 250 MB of the size limitation?

foreach(var outputData in outputList)
    await httpResponseData.Body.WriteAsync(outputData);


问:
Django crontab can’t connect database(Postgresql) with docker; no such table err
I am using django and postgresql. I am using django-crontab to change the data.

It runs well in the local environment, but we use docker to deploy and watch, and I confirmed that when cron runs, we refer to sqlite3.

I also made a separate cron container in docker composite and ran it, I am using it incorrectly because I am a beginner. Help me

#goods/cron.py
from goods.models import Goods
def test():
    print(Goods.objects.all())
```
<p>./docker-compose.yml</p>
<pre class="lang-py prettyprint-override"><code>version: '3.8'

volumes:
  postgres: {}
  django_media: {}
  django_static: {}
  static_volume: {}

services:

  postgres:
    container_name: postgres
    image: postgres:14.5
    volumes:
      - postgres:/var/lib/postgresql/data/
    environment:
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_DB
    restart: always

  nginx:
    container_name: nginx
    image: nginx:1.23.2
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
      - django_media:/media/
      - django_static:/static/
    depends_on:
      - asgiserver
      - backend
    restart: always
django_backend:/app/media
  backend:  host:container
    container_name: django_backend
    build: .
    entrypoint: sh -c "python manage.py migrate && gunicorn handsup.wsgi --workers=5 -b 0.0.0.0:8000"
    restart: always
    volumes:
      - ./:/app/
      - /etc/localtime:/etc/localtime:ro
      - django_media:/app/media/
      - django_static:/app/static/
    environment: #
      - DEBUG
      - POSTGRES_DB
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_HOST
      - POSTGRES_PORT
    depends_on:
      - postgres
  redis:
    image: redis:5

  asgiserver:
    build: .
    command: daphne -b 0.0.0.0 -p 8080 handsup.asgi:application

    volumes:
      - ./:/app/
    restart: always
    environment:
      - DEBUG
      - POSTGRES_DB
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_HOST
      - POSTGRES_PORT
    depends_on:
      - redis
      - postgres

  cron:
    build: .
    restart: always
    volumes:
      - ./:/app/
    depends_on:
      - postgres
      - backend
    environment: #
      - DEBUG
      - POSTGRES_DB
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_HOST
      - POSTGRES_PORT
    command: cron -f  # as a long-running foreground process
</code>```

./Dockerfile

FROM python:3.10.8

ENV PYTHONDONTWRITEBYTECODE 1

ENV PYTHONUNBUFFERED 1

RUN mkdir /app/

WORKDIR /app/

RUN apt-get update -y
RUN apt-get install -y cron

COPY ./requirements.txt .

COPY ./ /app/

RUN pip install --no-cache-dir -r requirements.txt

# RUN service cron start
ENTRYPOINT ["./docker-entrypoint.sh"]

RUN pip install gunicorn psycopg2
```
<p>./docker-entrypoint.sh</p>
<pre class="lang-bash prettyprint-override"><code>
# If this is going to be a cron container, set up the crontab.
if [ "$1" = cron ]; then
  ./manage.py crontab add
fi

# Launch the main container command passed as arguments.
exec "$@"
</code>```

I referred to the contents below.

How to make django-crontab execute commands in Docker container?

Body:
I am using django and postgresql. I am using django-crontab to change the data.

It runs well in the local environment, but we use docker to deploy and watch, and I confirmed that when cron runs, we refer to sqlite3.

I also made a separate cron container in docker composite and ran it, I am using it incorrectly because I am a beginner. Help me

#goods/cron.py
from goods.models import Goods
def test():
    print(Goods.objects.all())

./docker-compose.yml

version: '3.8'

volumes:
  postgres: {}
  django_media: {}
  django_static: {}
  static_volume: {}

services:

  postgres:
    container_name: postgres
    image: postgres:14.5
    volumes:
      - postgres:/var/lib/postgresql/data/
    environment:
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_DB
    restart: always

  nginx:
    container_name: nginx
    image: nginx:1.23.2
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
      - django_media:/media/
      - django_static:/static/
    depends_on:
      - asgiserver
      - backend
    restart: always
django_backend:/app/media
  backend:  host:container
    container_name: django_backend
    build: .
    entrypoint: sh -c "python manage.py migrate && gunicorn handsup.wsgi --workers=5 -b 0.0.0.0:8000"
    restart: always
    volumes:
      - ./:/app/
      - /etc/localtime:/etc/localtime:ro
      - django_media:/app/media/
      - django_static:/app/static/
    environment: #
      - DEBUG
      - POSTGRES_DB
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_HOST
      - POSTGRES_PORT
    depends_on:
      - postgres
  redis:
    image: redis:5

  asgiserver:
    build: .
    command: daphne -b 0.0.0.0 -p 8080 handsup.asgi:application

    volumes:
      - ./:/app/
    restart: always
    environment:
      - DEBUG
      - POSTGRES_DB
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_HOST
      - POSTGRES_PORT
    depends_on:
      - redis
      - postgres

  cron:
    build: .
    restart: always
    volumes:
      - ./:/app/
    depends_on:
      - postgres
      - backend
    environment: #
      - DEBUG
      - POSTGRES_DB
      - POSTGRES_USER
      - POSTGRES_PASSWORD
      - POSTGRES_HOST
      - POSTGRES_PORT
    command: cron -f  # as a long-running foreground process

./Dockerfile

FROM python:3.10.8

ENV PYTHONDONTWRITEBYTECODE 1

ENV PYTHONUNBUFFERED 1

RUN mkdir /app/

WORKDIR /app/

RUN apt-get update -y
RUN apt-get install -y cron

COPY ./requirements.txt .

COPY ./ /app/

RUN pip install --no-cache-dir -r requirements.txt

# RUN service cron start
ENTRYPOINT ["./docker-entrypoint.sh"]

RUN pip install gunicorn psycopg2

./docker-entrypoint.sh

# If this is going to be a cron container, set up the crontab.
if [ "$1" = cron ]; then
  ./manage.py crontab add
fi

# Launch the main container command passed as arguments.
exec "$@"

I referred to the contents below.

How to make django-crontab execute commands in Docker container?


问:
"Could not get audio input for record source 7" : SipAudioCall.start() Android 2.3.3 on Samsung GT-I9001 (Samsung Galaxy S Plus) doesn't work
I'm trying to start sample VoIP application on my Samsung Galaxy S. In the emulator application works just like a charm but during test on the phone I get :

```<code>09-20 13:41:57.874: VERBOSE/AudioPolicyManager(114): getDeviceForStrategy() strategy 3, device 2
09-20 13:41:57.874: VERBOSE/AudioPolicyManager(114): setOutputDevice() output 1 device 0 delayMs 0
09-20 13:41:57.874: VERBOSE/AudioPolicyManager(114): setOutputDevice() setting same device 0 or null device for output 1
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): getDeviceForStrategy() from cache strategy 1, device 2
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): getOutput() stream 0, samplingRate 0, format 0, channels c, flags 0
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): getDeviceForStrategy() from cache strategy 1, device 2
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): getOutput() stream 0, samplingRate 8000, format 1, channels 4, flags 0
09-20 13:41:57.884: WARN/AudioPolicyManager(114): getInput() invalid input source 7
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): getDeviceForInputSource()input source 7, device 00000000
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): getInput() inputSource 7, samplingRate 8000, format 1, channels 10, acoustics 0
09-20 13:41:57.884: ERROR/AudioRecord(4228): Could not get audio input for record source 7
09-20 13:41:57.884: ERROR/AudioGroup(4228): cannot initialize audio device
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): releaseOutput()
</code>```

The result is that nothing is captured by the phone and no voice is played through the speaker.

Thank you for help.

Body:
I'm trying to start sample VoIP application on my Samsung Galaxy S. In the emulator application works just like a charm but during test on the phone I get :

09-20 13:41:57.874: VERBOSE/AudioPolicyManager(114): getDeviceForStrategy() strategy 3, device 2
09-20 13:41:57.874: VERBOSE/AudioPolicyManager(114): setOutputDevice() output 1 device 0 delayMs 0
09-20 13:41:57.874: VERBOSE/AudioPolicyManager(114): setOutputDevice() setting same device 0 or null device for output 1
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): getDeviceForStrategy() from cache strategy 1, device 2
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): getOutput() stream 0, samplingRate 0, format 0, channels c, flags 0
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): getDeviceForStrategy() from cache strategy 1, device 2
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): getOutput() stream 0, samplingRate 8000, format 1, channels 4, flags 0
09-20 13:41:57.884: WARN/AudioPolicyManager(114): getInput() invalid input source 7
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): getDeviceForInputSource()input source 7, device 00000000
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): getInput() inputSource 7, samplingRate 8000, format 1, channels 10, acoustics 0
09-20 13:41:57.884: ERROR/AudioRecord(4228): Could not get audio input for record source 7
09-20 13:41:57.884: ERROR/AudioGroup(4228): cannot initialize audio device
09-20 13:41:57.884: VERBOSE/AudioPolicyManager(114): releaseOutput()

The result is that nothing is captured by the phone and no voice is played through the speaker.

Thank you for help.


问:
java spring boot problem : server can not find the design jsp file even though the file's link has been added to the decorators.xml file?
I am studying Java Spring Boot and here is my problem.

I wrote a very simple DemoSpring program and when I started the server, the link http://localhost:8888/DemoSpringMVC/ worked perfectly.

I added 2 files into those folder like those links :

```<code>src/main/webapp/WEB-INF/views/layouts/user/user.jsp
src/main/webapp/WEB-INF/views/layouts/user/index.jsp
</code>```

And I coded file decorators.xml like this

```<code><decorators defaultdir="/WEB_INF/views/layouts">
    <decorator name="user" page="user.jsp">
        <pattern>/trang-chu/*</pattern>
    </decorator>
    <decorator name="admin" page="admin.jsp">
        <pattern>/quan-tri/*</pattern>
    </decorator>
</decorators>
</code>```

But when I paste this link http://localhost:8888/DemoSpringMVC/trang-chu/, it said to me that I got this error

As you can see, it said to me that javax.servlet.ServletException: JSP file [/WEB_INF/views/layouts/user.jsp] not found ? So I think that the error is it did not find the file user.jsp ?

I ran the clean command, but still got this error. And I change the tomcat version 8 and 10, but the error still there, so maybe it is not because of the tomcat version ?

Should I wrote the decorators.xml file again?

Here is my code, if you need to reference

```<code>https://github.com/nguyencuc2586/Spring3.3
</code>```

Could you please give me some advices for this problem ? Thank you in advance.

Body:
I am studying Java Spring Boot and here is my problem.

I wrote a very simple DemoSpring program and when I started the server, the link http://localhost:8888/DemoSpringMVC/ worked perfectly.

I added 2 files into those folder like those links :

src/main/webapp/WEB-INF/views/layouts/user/user.jsp
src/main/webapp/WEB-INF/views/layouts/user/index.jsp

And I coded file decorators.xml like this

<decorators defaultdir="/WEB_INF/views/layouts">
    <decorator name="user" page="user.jsp">
        <pattern>/trang-chu/*</pattern>
    </decorator>
    <decorator name="admin" page="admin.jsp">
        <pattern>/quan-tri/*</pattern>
    </decorator>
</decorators>

But when I paste this link http://localhost:8888/DemoSpringMVC/trang-chu/, it said to me that I got this error

As you can see, it said to me that javax.servlet.ServletException: JSP file [/WEB_INF/views/layouts/user.jsp] not found ? So I think that the error is it did not find the file user.jsp ?

I ran the clean command, but still got this error. And I change the tomcat version 8 and 10, but the error still there, so maybe it is not because of the tomcat version ?

Should I wrote the decorators.xml file again?

Here is my code, if you need to reference

https://github.com/nguyencuc2586/Spring3.3

Could you please give me some advices for this problem ? Thank you in advance.


问:
How can I use tasks to edit a document in a db with discord.py?
```<code>async def check():
    if message.channel.id == 1053882363467284641:
        user_id = message.content
        member = client.get_user(int(user_id))
        try:
            await member.send("Thank you for voting! Vote rewards will come in the near future. :soontm:")
            votedb.votes.insert_one(
                {
                    "user_id": member.id,
                    "voted": "true"
                }
            )
            check = list(votedb.votes.find({"user_id": member.id}))
            for w in check:
                voted = w.get('voted')
        except:
            votedb.votes.insert_one(
                {
                    "user_id": member.id,
                    "voted": "true"
                }
            )
            check = list(votedb.votes.find({"user_id": member.id}))
            for w in check:
                voted = w.get('voted')

    else:
        return

@client.event
async def on_message(message):
    await check()
    await client.process_commands(message)

@tasks.loop(seconds=60)
async def my_loop():
    check()
    votedb.votes.update_one({"voted": voted},{"$set":{"voted": "false"}})
</code>```

So I'm trying to make vote only commands and I'm using mongodb to save if the user voted. I used an on_message event and webhooks to send the user id in a private channel and the bot can take it and message the member and add a document to the db. The task doesn't work though and it doesn't update the document after a certain time (in this case after 60 seconds) it only makes it and doesn't update it.

Body:
async def check():
    if message.channel.id == 1053882363467284641:
        user_id = message.content
        member = client.get_user(int(user_id))
        try:
            await member.send("Thank you for voting! Vote rewards will come in the near future. :soontm:")
            votedb.votes.insert_one(
                {
                    "user_id": member.id,
                    "voted": "true"
                }
            )
            check = list(votedb.votes.find({"user_id": member.id}))
            for w in check:
                voted = w.get('voted')
        except:
            votedb.votes.insert_one(
                {
                    "user_id": member.id,
                    "voted": "true"
                }
            )
            check = list(votedb.votes.find({"user_id": member.id}))
            for w in check:
                voted = w.get('voted')

    else:
        return

@client.event
async def on_message(message):
    await check()
    await client.process_commands(message)

@tasks.loop(seconds=60)
async def my_loop():
    check()
    votedb.votes.update_one({"voted": voted},{"$set":{"voted": "false"}})

So I'm trying to make vote only commands and I'm using mongodb to save if the user voted. I used an on_message event and webhooks to send the user id in a private channel and the bot can take it and message the member and add a document to the db. The task doesn't work though and it doesn't update the document after a certain time (in this case after 60 seconds) it only makes it and doesn't update it.