问:
LibreNMS API add_device not acting as expected
I am working on a python script to just add devices to LibreNMS a little bit faster, nothing fancy, pretty bare bones. I have no clue why it doesn't work though

here is my json file that is imported

{
    "hostname":"<removed for privacy>",
    "display":"<removed for privacy>",
    "version":"v3",
    "authlevel":"authPriv",
    "authname":"bitty",
    "authpass":"<removed for privacy>",
    "authalgo":"md5",
    "cryptopass":"<removed for privacy>",
    "cryptoalgo":"aes"
}
```
<p>and this is the python script currently</p>
<pre class="lang-py prettyprint-override"><code>import os
import json
with open('./hosts.json', 'r') as f:
    data=json.load(f)
curl = "curl -X POST -d "
auth = " -H 'X-Auth-Token:<removed for privacy>' "
url = "easter.int.colorado.edu/api/v0/devices"
add_device = (curl) + str(data) + (auth) + (url);
os.system(add_device)
</code>```

My understanding here is that 'json_data' should be providing the details that LibreNMS needs to add the device, while the rest of 'add_device' should be handling the rest of the curl command to the API. Running print(add_device) shows the output that is expected, however when os.system passes that along I get the following error output:

```<code>[root@chuuk manifests]# [root@chuuk manifests]# python3 librenms.py
curl: (6) Could not resolve host: <IP removed for privacy>,
curl: (6) Could not resolve host: display
curl: (6) Could not resolve host: <Hostname removed for privacy>,
curl: (6) Could not resolve host: version
curl: (6) Could not resolve host: v3,
curl: (6) Could not resolve host: authlevel
curl: (6) Could not resolve host: authPriv,
curl: (6) Could not resolve host: authname
curl: (6) Could not resolve host: <Account Name removed for privacy>,
curl: (6) Could not resolve host: authpass
curl: (6) Could not resolve host: <authpass removed for privacy>,
curl: (6) Could not resolve host: authalgo
curl: (6) Could not resolve host: md5,
curl: (6) Could not resolve host: cryptopass
curl: (6) Could not resolve host: <cryptopass removed for privacy> ,
curl: (6) Could not resolve host: cryptoalgo
curl: (3) [globbing] unmatched close brace/bracket in column 4
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.14.1</center>
</body>
</html>
</code>```

Feels like this should be very simple but I can't make it work. Any help is appreciated~!

Body:
I am working on a python script to just add devices to LibreNMS a little bit faster, nothing fancy, pretty bare bones. I have no clue why it doesn't work though

here is my json file that is imported

{
    "hostname":"<removed for privacy>",
    "display":"<removed for privacy>",
    "version":"v3",
    "authlevel":"authPriv",
    "authname":"bitty",
    "authpass":"<removed for privacy>",
    "authalgo":"md5",
    "cryptopass":"<removed for privacy>",
    "cryptoalgo":"aes"
}

and this is the python script currently

import os
import json
with open('./hosts.json', 'r') as f:
    data=json.load(f)
curl = "curl -X POST -d "
auth = " -H 'X-Auth-Token:<removed for privacy>' "
url = "easter.int.colorado.edu/api/v0/devices"
add_device = (curl) + str(data) + (auth) + (url);
os.system(add_device)

My understanding here is that 'json_data' should be providing the details that LibreNMS needs to add the device, while the rest of 'add_device' should be handling the rest of the curl command to the API. Running print(add_device) shows the output that is expected, however when os.system passes that along I get the following error output:

[root@chuuk manifests]# [root@chuuk manifests]# python3 librenms.py
curl: (6) Could not resolve host: <IP removed for privacy>,
curl: (6) Could not resolve host: display
curl: (6) Could not resolve host: <Hostname removed for privacy>,
curl: (6) Could not resolve host: version
curl: (6) Could not resolve host: v3,
curl: (6) Could not resolve host: authlevel
curl: (6) Could not resolve host: authPriv,
curl: (6) Could not resolve host: authname
curl: (6) Could not resolve host: <Account Name removed for privacy>,
curl: (6) Could not resolve host: authpass
curl: (6) Could not resolve host: <authpass removed for privacy>,
curl: (6) Could not resolve host: authalgo
curl: (6) Could not resolve host: md5,
curl: (6) Could not resolve host: cryptopass
curl: (6) Could not resolve host: <cryptopass removed for privacy> ,
curl: (6) Could not resolve host: cryptoalgo
curl: (3) [globbing] unmatched close brace/bracket in column 4

<title>301 Moved Permanently</title>

301 Moved Permanently

nginx/1.14.1

Feels like this should be very simple but I can't make it work. Any help is appreciated~!


来源: stackexchange

问:
Directus | Validation for related field are not working
When we configure the validation for child data model from parent data model using validation tab and then its not working in latest version ( 9.21.2), but it was working in old version like 9.10.0

I have created two entity such as Parent and Child.

I have related the Parent and child using Many to many relationship.

Parent Entity   with Many to many relationship with child:

Child Entity:

In parent, we child field (many to many field), and then there is a validation tab in which i have configure the validation for field in child, but its not working.

In following screenshot, you can see that i'm able to create child with empty title

Note: I dont want to configure the validation in Child data modal because i planned to create multiple relationship field with same Child data modal, so each time, i will use different validation rules, so Parent is the better place to configure it.

ContentLicense: CC BY-SA 4.0


问:
Firefox, Chrome: svg mask is missing in sprite symbol
everyone!

I have some SVG image with mask (for expamle):

```<code><svg width="173" height="173" viewBox="0 0 173 173" fill="none" xmlns="http://www.w3.org/2000/svg">
    <defs>
        <mask id="mask0_42_56" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="61" y="65" width="50" height="43">
            <rect x="61" y="65" width="50" height="43" rx="12" fill="#C4C4C4"/>
        </mask>
    </defs>
    <rect width="173" height="173" rx="16" fill="#F2F3F7"/>
    <g opacity="0.5">
        <g mask="url(#mask0_42_56)">
            <rect x="61" y="65" width="50" height="43" rx="0" fill="#C4C4C4"/>
            <path d="M100.062 80.3574C102.651 80.3574 104.75 78.2947 104.75 75.7502C104.75 73.2058 102.651 71.1431 100.062 71.1431C97.4736 71.1431 95.3749 73.2058 95.3749 75.7502C95.3749 78.2947 97.4736 80.3574 100.062 80.3574Z"
                  fill="#6C6C6C"/>
            <path d="M99.3574 90.5753C98.0109 89.2622 95.8359 89.2336 94.4531 90.5101L82.875 101.207V111.071H108.656C109.951 111.071 111 110.048 111 108.786V101.929L99.3574 90.5753Z"
                  fill="#6C6C6C"/>
            <path d="M104.75 111.071L78.0929 84.4931C76.6965 83.1008 74.441 83.0706 73.0069 84.424L61 95.7654V108.648C61 109.987 62.0877 111.071 63.4306 111.071H104.75Z"
                  fill="#6C6C6C"/>
        </g>
    </g>
</svg>
</code>```

I wanna bundle all of svg images on my project in one svg-sprite. I use simple gulp script for this, a lot of images displayed correctly. But images who contain mask displayed without mask. Mask id and attributes with using mask id match. The root of the incorrect display just in than symbol doesn't see mask with this id.

I have solution for Firefox. Move mask tag with chilren from symbol tag in parent svg tag.

```<code><?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <defs>
        <mask id="ara" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="61" y="65" width="50" height="43">
            <rect x="61" y="65" width="50" height="43" rx="12" fill="#C4C4C4"/>
        </mask>
    </defs>
    <symbol fill="none" viewBox="0 0 173 173" id="empty-cover" xmlns="http://www.w3.org/2000/svg">
        <rect width="173" height="173" rx="16" fill="#F2F3F7"/>
        <g mask="url(#ara)" opacity="0.5">
            <rect x="61" y="65" width="50" height="43" rx="0" fill="#C4C4C4"/>
            <path d="M100.062 80.357c2.589 0 4.688-2.062 4.688-4.607 0-2.544-2.099-4.607-4.688-4.607-2.588 0-4.687 2.063-4.687 4.607 0 2.545 2.099 4.607 4.687 4.607zM99.357 90.575a3.582 3.582 0 00-4.904-.065l-11.578 10.697v9.864h25.781c1.295 0 2.344-1.023 2.344-2.285v-6.857L99.357 90.575z"
              fill="#6C6C6C"/>
            <path d="M104.75 111.071L78.093 84.493a3.656 3.656 0 00-5.086-.069L61 95.765v12.883a2.426 2.426 0 002.43 2.423h41.32z"
              fill="#6C6C6C"/>
        </g>
    </symbol>

</code>```

This solution doesn't work for Chrome.

I tried to move mask to parent tag like in Firefox solution.
And I tried put mask to both places: root svg tag and symbol.

Body:
everyone!

I have some SVG image with mask (for expamle):

<svg width="173" height="173" viewBox="0 0 173 173" fill="none" xmlns="http://www.w3.org/2000/svg">
    <defs>
        <mask id="mask0_42_56" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="61" y="65" width="50" height="43">
            <rect x="61" y="65" width="50" height="43" rx="12" fill="#C4C4C4"/>
        </mask>
    </defs>
    <rect width="173" height="173" rx="16" fill="#F2F3F7"/>
    <g opacity="0.5">
        <g mask="url(#mask0_42_56)">
            <rect x="61" y="65" width="50" height="43" rx="0" fill="#C4C4C4"/>
            <path d="M100.062 80.3574C102.651 80.3574 104.75 78.2947 104.75 75.7502C104.75 73.2058 102.651 71.1431 100.062 71.1431C97.4736 71.1431 95.3749 73.2058 95.3749 75.7502C95.3749 78.2947 97.4736 80.3574 100.062 80.3574Z"
                  fill="#6C6C6C"/>
            <path d="M99.3574 90.5753C98.0109 89.2622 95.8359 89.2336 94.4531 90.5101L82.875 101.207V111.071H108.656C109.951 111.071 111 110.048 111 108.786V101.929L99.3574 90.5753Z"
                  fill="#6C6C6C"/>
            <path d="M104.75 111.071L78.0929 84.4931C76.6965 83.1008 74.441 83.0706 73.0069 84.424L61 95.7654V108.648C61 109.987 62.0877 111.071 63.4306 111.071H104.75Z"
                  fill="#6C6C6C"/>
        </g>
    </g>
</svg>

I wanna bundle all of svg images on my project in one svg-sprite. I use simple gulp script for this, a lot of images displayed correctly. But images who contain mask displayed without mask. Mask id and attributes with using mask id match. The root of the incorrect display just in than symbol doesn't see mask with this id.

I have solution for Firefox. Move mask tag with chilren from symbol tag in parent svg tag.

<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <defs>
        <mask id="ara" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="61" y="65" width="50" height="43">
            <rect x="61" y="65" width="50" height="43" rx="12" fill="#C4C4C4"/>
        </mask>
    </defs>
    <symbol fill="none" viewBox="0 0 173 173" id="empty-cover" xmlns="http://www.w3.org/2000/svg">
        <rect width="173" height="173" rx="16" fill="#F2F3F7"/>
        <g mask="url(#ara)" opacity="0.5">
            <rect x="61" y="65" width="50" height="43" rx="0" fill="#C4C4C4"/>
            <path d="M100.062 80.357c2.589 0 4.688-2.062 4.688-4.607 0-2.544-2.099-4.607-4.688-4.607-2.588 0-4.687 2.063-4.687 4.607 0 2.545 2.099 4.607 4.687 4.607zM99.357 90.575a3.582 3.582 0 00-4.904-.065l-11.578 10.697v9.864h25.781c1.295 0 2.344-1.023 2.344-2.285v-6.857L99.357 90.575z"
              fill="#6C6C6C"/>
            <path d="M104.75 111.071L78.093 84.493a3.656 3.656 0 00-5.086-.069L61 95.765v12.883a2.426 2.426 0 002.43 2.423h41.32z"
              fill="#6C6C6C"/>
        </g>
    </symbol>

This solution doesn't work for Chrome.

I tried to move mask to parent tag like in Firefox solution.
And I tried put mask to both places: root svg tag and symbol.


问:
Django Channels Consumer won't execute method
I'm trying to develop a chat application that saves messages in the database via a WebSocket with Django Channels.

settings.py:

```<code>ASGI_APPLICATION = "app.asgi.application"
CHANNEL_LAYERS = {
    'default': {
    'BACKEND': "channels.layers.InMemoryChannelLayer",
    },
}
</code>```

asgi.py:

```<code>from api.routing import websocket_urlpatterns

application = ProtocolTypeRouter({
"http" : get_asgi_application(),
"websocket": JWTAuthMiddleware(
    URLRouter(
        websocket_urlpatterns
    )
  ),
})
</code>```

routing.py:

```<code>websocket_urlpatterns = [
    path('ws/chat/<chat_uuid>/', consumers.ChatConsumer.as_asgi())
]
</code>```

consumers.py

```<code>class ChatConsumer(AsyncJsonWebsocketConsumer):
    @database_sync_to_async
    def create_message(self, sender, message, chat):
        if sender:
            if content_validation(message):
                chat = Chat.objects.filter(uuid=chat)
                if chat.exists():
                    msg = Message.objects.create(sent_by=sender, content=message)
                    chat.first().messages.add(msg)

                    return msg

        return None

    @database_sync_to_async
    def check_security(self, user, uuid):
        # Chat has to exist and user has to be part of it
        chat = Chat.objects.filter(Q(Q(user1=user) | Q(user2=user)) & Q(uuid=uuid))
        if chat.exists():
            return True

        return False

    async def connect(self):
        self.chat_uuid = self.scope['url_route']['kwargs']['chat_uuid']
        self.room_group_name = 'chat_%s' % self.chat_uuid

        user = self.scope["user"]

        if user:
            check = await self.check_security(user, self.chat_uuid)
            if check == True:
                # Join room group
                await self.channel_layer.group_add(
                    self.room_group_name,
                    self.channel_name
                )

                await self.accept()

        await self.disconnect(401)

    async def disconnect(self, close_code):
        # Leave room group
        await self.channel_layer.group_discard(
            self.room_group_name,
            self.channel_name
        )

    # Receive message from WebSocket
    async def receive(self, text_data):
        text_data_json = json.loads(text_data)
        message = text_data_json['message']
        name = text_data_json['name']
        print(text_data_json)

        user = self.scope["user"]
        # Is this smart? User not receiving a message for whatever reason won't trigger the create event
        new_msg = await self.create_message(user, message, self.chat_uuid)

        if new_msg != None:
            # Send message to room group
            print("Receiving")
            await self.channel_layer.group_send(
                self.room_group_name,
                {
                    'type': 'chat_message',
                    'message': message,
                    'name': name
                }
            )
        else:
            await self.channel_layer.group_send(
                self.room_group_name,
                {
                    'type': 'content_guideline_violation',
                    'message': "",
                    'name': name
                }
            )

    # Receive message from room group
    async def chat_message(self, event):
        message = event['message']
        name = event['name']
        print(event)

        # Send message to WebSocket
        print("Sending")
        await self.send(text_data=json.dumps({
            'message': message,
            'name': name
        }))
</code>```

I won't post the JWTAuthMiddleware for now since everything worked fine after first implementing it.
The problem is that even though connect and receive are being executed just fine, it just won't execute chat_message anymore for whatever reason.
My Postman requests are looking like the following:

```<code>ws://127.0.0.1:8000/ws/chat/<chat_uuid>/?Bearer=<jwt_token>
</code>```

Postman is able to connect to the websocket and it sends messages as well as saves them in a database but it doesn't show these messages for the other user in the chat.

Body:
I'm trying to develop a chat application that saves messages in the database via a WebSocket with Django Channels.

settings.py:

ASGI_APPLICATION = "app.asgi.application"
CHANNEL_LAYERS = {
    'default': {
    'BACKEND': "channels.layers.InMemoryChannelLayer",
    },
}

asgi.py:

from api.routing import websocket_urlpatterns

application = ProtocolTypeRouter({
"http" : get_asgi_application(),
"websocket": JWTAuthMiddleware(
    URLRouter(
        websocket_urlpatterns
    )
  ),
})

routing.py:

websocket_urlpatterns = [
    path('ws/chat/<chat_uuid>/', consumers.ChatConsumer.as_asgi())
]

consumers.py

class ChatConsumer(AsyncJsonWebsocketConsumer):
    @database_sync_to_async
    def create_message(self, sender, message, chat):
        if sender:
            if content_validation(message):
                chat = Chat.objects.filter(uuid=chat)
                if chat.exists():
                    msg = Message.objects.create(sent_by=sender, content=message)
                    chat.first().messages.add(msg)

                    return msg

        return None

    @database_sync_to_async
    def check_security(self, user, uuid):
        # Chat has to exist and user has to be part of it
        chat = Chat.objects.filter(Q(Q(user1=user) | Q(user2=user)) & Q(uuid=uuid))
        if chat.exists():
            return True

        return False

    async def connect(self):
        self.chat_uuid = self.scope['url_route']['kwargs']['chat_uuid']
        self.room_group_name = 'chat_%s' % self.chat_uuid

        user = self.scope["user"]

        if user:
            check = await self.check_security(user, self.chat_uuid)
            if check == True:
                # Join room group
                await self.channel_layer.group_add(
                    self.room_group_name,
                    self.channel_name
                )

                await self.accept()

        await self.disconnect(401)

    async def disconnect(self, close_code):
        # Leave room group
        await self.channel_layer.group_discard(
            self.room_group_name,
            self.channel_name
        )

    # Receive message from WebSocket
    async def receive(self, text_data):
        text_data_json = json.loads(text_data)
        message = text_data_json['message']
        name = text_data_json['name']
        print(text_data_json)

        user = self.scope["user"]
        # Is this smart? User not receiving a message for whatever reason won't trigger the create event
        new_msg = await self.create_message(user, message, self.chat_uuid)

        if new_msg != None:
            # Send message to room group
            print("Receiving")
            await self.channel_layer.group_send(
                self.room_group_name,
                {
                    'type': 'chat_message',
                    'message': message,
                    'name': name
                }
            )
        else:
            await self.channel_layer.group_send(
                self.room_group_name,
                {
                    'type': 'content_guideline_violation',
                    'message': "",
                    'name': name
                }
            )

    # Receive message from room group
    async def chat_message(self, event):
        message = event['message']
        name = event['name']
        print(event)

        # Send message to WebSocket
        print("Sending")
        await self.send(text_data=json.dumps({
            'message': message,
            'name': name
        }))

I won't post the JWTAuthMiddleware for now since everything worked fine after first implementing it.
The problem is that even though connect and receive are being executed just fine, it just won't execute chat_message anymore for whatever reason.
My Postman requests are looking like the following:

ws://127.0.0.1:8000/ws/chat/<chat_uuid>/?Bearer=<jwt_token>

Postman is able to connect to the websocket and it sends messages as well as saves them in a database but it doesn't show these messages for the other user in the chat.


问:
why that "returnSize" pointer is used?
```<code>double* convertTemperature(double celsius, int* returnSize){
 double* ans=malloc(2*sizeof(double));
    double kelvin=(double)(celsius+273.15);
    double fah=(double)(celsius*1.80+32.00);
    ans[0]=kelvin;
    ans[1]=fah;
    *(returnSize)=2;
    return ans;
}
</code>```

In that "convertTemperature" function, why "*(returnSize)=2;" is used??

i can understand what just happen. can anybody help please? thanks

Title: why that "returnSize" pointer is used?

Body:
double* convertTemperature(double celsius, int* returnSize){
 double* ans=malloc(2*sizeof(double));
    double kelvin=(double)(celsius+273.15);
    double fah=(double)(celsius*1.80+32.00);
    ans[0]=kelvin;
    ans[1]=fah;
    *(returnSize)=2;
    return ans;
}

In that "convertTemperature" function, why "*(returnSize)=2;" is used??

i can understand what just happen. can anybody help please? thanks


问:
Javascript how do we do our location within the radius of the location then the result is true?
Javascript how do we do our location within the radius of the location then the result is true?
the client location is clientLatlng and for the radius or the main location of radius is myLatlng
so when our location is within the radius location it produces the word success
make it in javascript

```<code><style>
    * {
    font-family: sans-serif;
    }
    #debug {
        margin: 20px;
    }
    #map-canvas{
        height: 400px;
        width: 700px;
        border: 1px solid black;
    }

</style>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
    <div id="map-canvas"></div>
</body>
</html>

<script>
    var canvas = document.getElementById('map-canvas');
    var myLatlng = new google.maps.LatLng(-6.16936,106.70772);

    var mapOptions = {
        zoom: 20,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(canvas, mapOptions);

    var circleOptions = {
        draggable: false,
        editable: false,
        strokeColor: '#eeeeee',
        strokeOpacity: 0.8,
        strokeWeight: 1,
        fillColor: '#FF0000',
        fillOpacity: 0.15,
        map: map,
        center: myLatlng,
        radius: 20
    };
    var circle = new google.maps.Circle(circleOptions);

    var clientLatlng = new google.maps.LatLng(-6.16936,106.70797);
    if(clientLatlng){

    }
</script>
</code>```

if our location is within the radius then it produces the word "success"

Body:
Javascript how do we do our location within the radius of the location then the result is true?
the client location is clientLatlng and for the radius or the main location of radius is myLatlng
so when our location is within the radius location it produces the word success
make it in javascript

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

if our location is within the radius then it produces the word "success"


问:
How do i get the reference of an object in AudioFile and add it to an array audioData within the audioManager class?
I am trying to write code which takes the reference of an object created within the AudioFile class and add them to a list called AudioData within a seperate class called AudioManager which is going to be used to manage instances of AudioFile.

I have tried to do this using an AudioCode and nextCode function which is the requirements of my project and have had no luck as of yet.


问:
Fast way to access elements of a Vector in a given order
I have a vector X of u32 that I need to access the elements of in a known order. There's another vector orderings containing a list of usize which is the order I need to access the elements of X in.

At the moment I'm doing:

```<code>for order in orderings.iter() {
    let val = X[*order];
    //do stuff with val
}
</code>```

Unfortunately this is pretty slow as I'm having to index into X every single iteration of the loop, is there a way I can just get the val for each loop directly without having to do this indexing that is faster?

Body:
I have a vector X of u32 that I need to access the elements of in a known order. There's another vector orderings containing a list of usize which is the order I need to access the elements of X in.

At the moment I'm doing:

for order in orderings.iter() {
    let val = X[*order];
    //do stuff with val
}

Unfortunately this is pretty slow as I'm having to index into X every single iteration of the loop, is there a way I can just get the val for each loop directly without having to do this indexing that is faster?


Title: How can I plot these values more clearly? (jagged line graph)

Body:
I have a dataset that looks similar to this:

> dput(df)
structure(list(X = c("5", "6", "7", "8", "9", "10", "11", "12",
"13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23",
"24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34",
"35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45",
"46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56",
"57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67",
"68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78",
"79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
"90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "100",
"101", "102", "103", "104", "105", "106", "107", "108", "109",
"110", "111", "112", "113", "114", "115", "116", "117", "118",
"119", "120", "121", "122", "123", "124", "125", "126", "127",
"128", "129", "130", "131", "132", "133", "134", "135", "136",
"137", "138", "139", "140", "141", "142", "143", "144", "145",
"146", "147", "148", "149", "150", "151", "152", "153", "154",
"155", "156", "157", "158", "159", "160", "161", "162", "163",
"164", "165", "166", "167", "168", "169", "170", "171", "172",
"173", "174", "175", "176", "177", "178", "179", "180", "181",
"182", "183", "184", "Showing 83 to 101 of 440 entries, 5 total columns"
), Date_Time = c("2021-01-06 08:13:00", "2021-01-06 08:14:00",
"2021-01-06 08:15:00", "2021-01-06 08:16:00", "2021-01-06 08:17:00",
"2021-01-06 08:18:00", "2021-01-06 08:19:00", "2021-01-06 08:20:00",
"2021-01-06 08:21:00", "2021-01-06 08:22:00", "2021-01-06 08:23:00",
"2021-01-06 08:24:00", "2021-01-06 08:25:00", "2021-01-06 08:26:00",
"2021-01-06 08:27:00", "2021-01-06 08:28:00", "2021-01-06 08:41:00",
"2021-01-06 08:42:00", "2021-01-06 08:43:00", "2021-01-06 08:44:00",
"2021-01-06 08:45:00", "2021-01-06 08:46:00", "2021-01-06 08:54:00",
"2021-01-06 08:59:00", "2021-01-06 09:00:00", "2021-01-06 09:01:00",
"2021-01-06 09:02:00", "2021-01-06 09:03:00", "2021-01-06 09:04:00",
"2021-01-06 09:33:00", "2021-01-06 09:34:00", "2021-01-06 09:35:00",
"2021-01-06 09:36:00", "2021-01-06 09:37:00", "2021-01-06 09:38:00",
"2021-01-04 14:01:00", "2021-01-04 13:31:00", "2021-01-04 13:32:00",
"2021-01-04 13:33:00", "2021-01-04 13:34:00", "2021-01-04 13:35:00",
"2021-01-04 13:36:00", "2021-01-04 13:37:00", "2021-01-04 13:38:00",
"2021-01-04 13:39:00", "2021-01-04 13:40:00", "2021-01-04 13:41:00",
"2021-01-04 13:42:00", "2021-01-04 13:43:00", "2021-01-04 13:44:00",
"2021-01-04 13:45:00", "2021-01-04 13:46:00", "2021-01-04 13:49:00",
"2021-01-04 13:50:00", "2021-01-04 13:51:00", "2021-01-04 13:52:00",
"2021-01-04 13:53:00", "2021-01-04 13:54:00", "2021-01-04 13:55:00",
"2021-01-05 13:02:00", "2021-01-04 07:54:00", "2021-01-03 20:23:00",
"2021-01-03 20:25:00", "2021-01-03 20:27:00", "2021-01-01 13:33:00",
"2021-01-01 13:35:00", "2021-01-01 13:36:00", "2021-01-01 13:37:00",
"2021-01-01 13:38:00", "2021-01-01 18:01:00", "2021-01-06 07:43:00",
"2021-01-06 07:45:00", "2021-01-06 07:46:00", "2021-01-06 07:48:00",
"2021-01-06 07:49:00", "2021-01-06 07:50:00", "2021-01-05 11:56:00",
"2021-01-05 11:56:00", "2021-01-01 18:09:00", "2021-01-01 18:10:00",
"2021-01-01 18:11:00", "2021-01-01 18:12:00", "2021-01-04 10:28:00",
"2021-01-04 10:29:00", "2021-01-04 10:30:00", "2021-01-06 17:18:00",
"2021-01-06 14:15:00", "2021-01-02 14:26:00", "2021-01-04 07:49:00",
"2021-01-04 07:50:00", "2021-01-04 07:51:00", "2021-01-04 08:04:00",
"2021-01-04 08:19:00", "2021-01-04 11:39:00", "2021-01-02 12:49:00",
"2021-01-02 12:50:00", "2021-01-02 12:51:00", "2021-01-02 12:52:00",
"2021-01-02 12:53:00", "2021-01-02 12:54:00", "2021-01-02 12:55:00",
"2021-01-02 12:56:00", "2021-01-02 12:57:00", "2021-01-02 12:58:00",
"2021-01-02 12:59:00", "2021-01-02 13:00:00", "2021-01-02 13:01:00",
"2021-01-02 13:02:00", "2021-01-02 13:12:00", "2021-01-02 13:13:00",
"2021-01-02 13:14:00", "2021-01-02 13:15:00", "2021-01-02 13:16:00",
"2021-01-02 13:17:00", "2021-01-02 13:18:00", "2021-01-04 08:32:00",
"2021-01-06 12:08:00", "2021-01-06 12:13:00", "2021-01-06 12:14:00",
"2021-01-06 12:15:00", "2021-01-06 12:16:00", "2021-01-06 12:17:00",
"2021-01-06 12:18:00", "2021-01-05 10:11:00", "2021-01-05 10:12:00",
"2021-01-05 10:13:00", "2021-01-02 09:22:00", "2021-01-02 09:25:00",
"2021-01-02 09:26:00", "2021-01-02 09:27:00", "2021-01-02 09:28:00",
"2021-01-02 09:29:00", "2021-01-04 12:05:00", "2021-01-04 12:06:00",
"2021-01-04 12:07:00", "2021-01-04 12:08:00", "2021-01-04 12:09:00",
"2021-01-04 12:18:00", "2021-01-06 07:35:00", "2021-01-06 07:36:00",
"2021-01-06 07:37:00", "2021-01-06 07:38:00", "2021-01-06 07:39:00",
"2021-01-06 07:40:00", "2021-01-06 07:41:00", "2021-01-06 07:42:00",
"2021-01-06 07:51:00", "2021-01-06 07:52:00", "2021-01-06 07:54:00",
"2021-01-02 07:32:00", "2021-01-02 07:35:00", "2021-01-03 13:08:00",
"2021-01-04 13:08:00", "2021-01-02 16:19:00", "2021-01-02 16:22:00",
"2021-01-02 16:25:00", "2021-01-02 16:26:00", "2021-01-02 16:30:00",
"2021-01-02 16:32:00", "2021-01-02 16:35:00", "2021-01-02 16:37:00",
"2021-01-02 16:38:00", "2021-01-02 07:52:00", "2021-01-02 07:53:00",
"2021-01-02 07:54:00", "2021-01-02 07:55:00", "2021-01-02 10:33:00",
"2021-01-02 10:34:00", "2021-01-02 10:35:00", "2021-01-02 10:36:00",
"2021-01-02 12:06:00", "2021-01-02 12:09:00", "2021-01-02 07:35:00",
"2021-01-01 10:30:00", "2021-01-01 10:31:00", "2021-01-01 10:32:00",
"2021-01-01 10:33:00", "2021-01-01 10:34:00", "2021-01-01 10:35:00",
"2021-01-01 10:36:00", ""), Chemical_x = c("Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", "Benzene", "Benzene",
"Benzene", "Benzene", "Benzene", "Benzene", ""), Value_X = c(1.6,
1.6, 1.6, 1.6, 1.6, 1.5, 1.5, 1.6, 1.6, 1.5, 1.6, 1.6, 1.6, 1.6,
1.6, 1.7, 1.8, 1.8, 1.7, 1.6, 1.6, 1.7, 1.7, 1.9, 1.9, 1.6, 1.7,
1.7, 1.8, 1.6, 1.5, 1.6, 1.6, 1.5, 1.5, 2.2, 3.4, 4.1, 4.6, 5.2,
5.2, 5.3, 5.4, 6, 6.5, 4.7, 3.3, 3.6, 3.8, 3.6, 3.3, 3.3, 2.3,
2.1, 2.1, 2.1, 1.9, 1.8, 1.8, 1.9, 1.4, 1.9, 1.9, 1.6, 1.7, 1.5,
2, 2.2, 2.2, 1.5, 1.5, 1.9, 2.1, 1.5, 2.1, 2.1, 1.5, 1.5, 1.5,
1.5, 1.6, 1.6, 1.5, 1.6, 1.7, 1.4, 1.5, 1.8, 1.5, 1.5, 1.5, 1.6,
1.4, 2.2, 1.6, 1.8, 1.7, 1.7, 1.6, 1.7, 1.8, 1.8, 2, 1.7, 1.8,
1.8, 1.8, 1.8, 1.5, 1.5, 1.5, 2, 2, 1.6, 1.9, 1.6, 1.5, 1.5,
1.5, 1.5, 1.5, 1.5, 1.5, 4.1, 3.7, 3.3, 3.6, 6.7, 5.6, 5.3, 5.9,
4.3, 2.3, 2.3, 2.3, 2.3, 2.3, 1.4, 4.4, 4.8, 4.8, 4.8, 3.4, 3,
2.8, 2.8, 4.6, 4.4, 3.9, 1.4, 1.5, 1.7, 1.7, 1.4, 1.5, 1.4, 1.4,
1.8, 1.8, 1.6, 1.4, 1.5, 2.1, 1.7, 2, 1.9, 1.6, 2.1, 2.2, 2.3,
1.7, 1.6, 1.7, 6.3, 4.7, 5.1, 4.4, 3.8, 3.8, 3.9, NA), Chemical_y = c("Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", "Propene",
"Propene", "Propene", "Propene", "Propene", "Propene", ""), Value_y = c(10,
10, 10, 10, 10, 10, 10, 0.5, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 8.7, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5,
9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 9.5, 10, 10, 10, 10, 10, 10, 10,
9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 8.65,
10, 9.15, 10, 10, 10, 10, 9.2, 9.2, 9.2, 10, 10, 10, 10, 10,
10, 10, 10, 9.2, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 8.9, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 8.9, 8.9, 8.9, 8.9, 8.9, 9.9, 9.9,
9.9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9.49,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9.02, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 8.9, 10, 10, 10, 10, 10, 10,
10, NA)), row.names = c(NA, -181L), class = "data.frame")

But when I plot the values, I get a graph that looks like this (somewhat jagged):

My concern is that, with the larger/real dataset, it looks even more jagged

Is there a better way to plot these values to get rid of the jagged lines and make it look like an actual cleaner version of a time-series plot?

Here is my code to create the plot:

fig <- plot_ly(df, type = 'scatter',
               mode = 'lines')%>%
  add_trace(x = ~Date_Time, y = ~Value_X, name = 'Benzene') %>%
  add_trace(x = ~Date_Time, y = ~Value_y, name = 'Propene')

fig <- fig %>%
  layout(
    xaxis = list(zerolinecolor = '#ffff',
                 zerolinewidth = 2,
                 gridcolor = 'ffff'),
    yaxis = list(zerolinecolor = '#ffff',
                 zerolinewidth = 2,
                 gridcolor = 'ffff'),
    plot_bgcolor='#e5ecf6')

fig


问:
Mesa - glCopyPixels is much slower on iris compared to i965
I'm working on a 3D application based on Blender 2.79 (which includes the old game engine), running on linux. Some more details about the system:

```<code>$ lsb_release -a | grep Description
Description:    Ubuntu 22.04.1 LTS
$ uname -r
5.15.0-46-lowlatency
$ lscpu | grep Intel
Model name:                    Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
</code>```

The application doesn't have much special about it except that it needs to copy every frame into memory. For this bge.texture.ImageTexture::refresh is used with its buffer parameter (see blender docs).

The problem I've been seeing is that the time spent in the refresh call is highly varied depending on whether I use i965 or iris as the driver. On the newer one, iris, I'm not capable of maintaining 60fps. I use the MESA_LOADER_DRIVER_OVERRIDE={i965,iris} environment variable.

This is not an issue on my current hardware, but I know that i965 does not work on newer hardware, in particular 12th gen intel CPUs.

I've produced some flame graphs when running each of those drivers. Here are the important (in my opinion) bits:

i965 (fast)

iris (slow)

It looks like with i965, after _mesa_ReadPixelsARB, the code jumps into the intel-specific part of mesa, while with iris it uses something called the state-tracker. I suppose this is a module that bridges mesa and Gallium3D, but I'm not confident that this information is helpful.

I also attached a debugger to the blender process to find that the _st_ReadPixels seems to enter the "slow" path, according to the author (see source)

At this point I would greatly appreciate someone more proficient at mesa and opengl to have a look at the information I have and help make sense of it.

Body:
I'm working on a 3D application based on Blender 2.79 (which includes the old game engine), running on linux. Some more details about the system:

$ lsb_release -a | grep Description
Description:    Ubuntu 22.04.1 LTS
$ uname -r
5.15.0-46-lowlatency
$ lscpu | grep Intel
Model name:                    Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz

The application doesn't have much special about it except that it needs to copy every frame into memory. For this bge.texture.ImageTexture::refresh is used with its buffer parameter (see blender docs).

The problem I've been seeing is that the time spent in the refresh call is highly varied depending on whether I use i965 or iris as the driver. On the newer one, iris, I'm not capable of maintaining 60fps. I use the MESA_LOADER_DRIVER_OVERRIDE={i965,iris} environment variable.

This is not an issue on my current hardware, but I know that i965 does not work on newer hardware, in particular 12th gen intel CPUs.

I've produced some flame graphs when running each of those drivers. Here are the important (in my opinion) bits:

i965 (fast)

iris (slow)

It looks like with i965, after _mesa_ReadPixelsARB, the code jumps into the intel-specific part of mesa, while with iris it uses something called the state-tracker. I suppose this is a module that bridges mesa and Gallium3D, but I'm not confident that this information is helpful.

I also attached a debugger to the blender process to find that the _st_ReadPixels seems to enter the "slow" path, according to the author (see source)

At this point I would greatly appreciate someone more proficient at mesa and opengl to have a look at the information I have and help make sense of it.


问:
Part of my page not presented properly on safari browser
My keyboard is showing as I wanted it to on Chrome and Firefox, but when I try it on Safari (on the phone!) looks like it does not make the width of the keys responsive. They stay the same width and then some of them are pushed to the next line. How can I rectify this?

html

```<code><div class="play-area">
            <div id="key-container"></div>
        </div>
</code>```

CSS

```<code>#key-container {
    width: 100%;
    height: 123px;
    background-color: transparent;
    margin: auto;
}

#key-container button {
    height: 35px;
    width: 6%;
    max-width: 55px;
    margin: 3px;
    border-radius: 6px;
    border: none;
    font-size: 1.1rem;
    color: #ffffff;
    background-color: #2525253c;
    outline: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#key-container button:active {
    background-color: #ffffff;
    color: #00c8ff;
}

#key-container button:disabled {
    background: -webkit-linear-gradient(#000000, #00c8ff);
    background-clip: padding-box;
    -webkit-text-fill-color: #ffffff;
}
</code>```

JS

```<code>function createKeys() {

const keyboard = document.querySelector("#key-container");
const keys = [
    "q", "w", "e", "r", "t", "y", "u", "i", "o", "p",
    "a", "s", "d", "f", "g", "h", "j", "k", "l",
    "z", "x", "c", "v", "b", "n", "m"
];

keys.forEach(key => {
    const buttonElement = document.createElement("button");
    const insertLineBreak = ["p", "l"].indexOf(key) !== -1;
    buttonElement.textContent = key;
    buttonElement.setAttribute("id", key);
    buttonElement.addEventListener('click', () => handleClick(key));
    keyboard.appendChild(buttonElement);

    if (insertLineBreak) {
        keyboard.appendChild(document.createElement("br"));
    }
});
}

</code>```

Body:
My keyboard is showing as I wanted it to on Chrome and Firefox, but when I try it on Safari (on the phone!) looks like it does not make the width of the keys responsive. They stay the same width and then some of them are pushed to the next line. How can I rectify this?

html

CSS

#key-container {
    width: 100%;
    height: 123px;
    background-color: transparent;
    margin: auto;
}

#key-container button {
    height: 35px;
    width: 6%;
    max-width: 55px;
    margin: 3px;
    border-radius: 6px;
    border: none;
    font-size: 1.1rem;
    color: #ffffff;
    background-color: #2525253c;
    outline: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#key-container button:active {
    background-color: #ffffff;
    color: #00c8ff;
}

#key-container button:disabled {
    background: -webkit-linear-gradient(#000000, #00c8ff);
    background-clip: padding-box;
    -webkit-text-fill-color: #ffffff;
}

JS

function createKeys() {

const keyboard = document.querySelector("#key-container");
const keys = [
    "q", "w", "e", "r", "t", "y", "u", "i", "o", "p",
    "a", "s", "d", "f", "g", "h", "j", "k", "l",
    "z", "x", "c", "v", "b", "n", "m"
];

keys.forEach(key => {
    const buttonElement = document.createElement("button");
    const insertLineBreak = ["p", "l"].indexOf(key) !== -1;
    buttonElement.textContent = key;
    buttonElement.setAttribute("id", key);
    buttonElement.addEventListener('click', () => handleClick(key));
    keyboard.appendChild(buttonElement);

    if (insertLineBreak) {
        keyboard.appendChild(document.createElement("br"));
    }
});
}


问:
Create C++ DLL with Visual Studio 2019 for Windows 98
I have the source code of an old C++ DLL that I want to add a new function to. The DLL was written years ago for the "Windows 98" operating system.

So I have the following question:

Is it possible to recompile the DLL with Visual Studio 2019 and Windows 10 from the existing source code?
Which settings do I have to make?
What do I have to be aware of?
Which compiler or tool do I need and how do I set it up?


问:
Pipenv keeps pointing to existing virtual environment
Whenever I want to create a new virtual environment in an empty directory, pipenv always points to an existing environment although I'm not in that environment. Notice how it also creates the Pipfile in the directory where pipenv points to, instead of the current directory:

```<code>[philippbunke@fedora market_maker]$ pipenv --python 3.10
Virtualenv already exists!
Removing existing virtualenv...
Creating a virtualenv for this project...
Pipfile: /home/philippbunke/Programs/repos/work/playground/Pipfile
Using /usr/bin/python3 (3.10.6) to create virtualenv...
⠋ Creating virtual environment...created virtual environment CPython3.10.6.final.0-64 in 558ms
  creator CPython3Posix(dest=/home/philippbunke/.local/share/virtualenvs/playground-QFVQT-z1, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/philippbunke/.local/share/virtualenv)
    added seed packages: pip==21.3.1, setuptools==58.3.0, wheel==0.37.0
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment!
Virtualenv location: /home/philippbunke/.local/share/virtualenvs/playground-QFVQT-z1

</code>```

Does anyone has an idea where this is coming from?

P.S.
When I try to install a package I get the following error:

```<code>[philippbunke@fedora market_maker]$ pipenv install qpsolvers
Installing qpsolvers...
Adding qpsolvers to Pipfile's [packages]...
✔ Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed!

CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement python>=3.6 (from versions: none)
[ResolutionFailure]:   File "/home/philippbunke/.local/lib/python3.10/site-packages/pipenv/resolver.py", line 743, in _main
[ResolutionFailure]:       resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
[ResolutionFailure]:   File "/home/philippbunke/.local/lib/python3.10/site-packages/pipenv/resolver.py", line 704, in resolve_packages
[ResolutionFailure]:       results, resolver = resolve(
[ResolutionFailure]:   File "/home/philippbunke/.local/lib/python3.10/site-packages/pipenv/resolver.py", line 685, in resolve
[ResolutionFailure]:       return resolve_deps(
[ResolutionFailure]:   File "/home/philippbunke/.local/lib/python3.10/site-packages/pipenv/utils.py", line 1370, in resolve_deps
[ResolutionFailure]:       results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
[ResolutionFailure]:   File "/home/philippbunke/.local/lib/python3.10/site-packages/pipenv/utils.py", line 1099, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "/home/philippbunke/.local/lib/python3.10/site-packages/pipenv/utils.py", line 877, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for python>=3.6
</code>```

Body:
Whenever I want to create a new virtual environment in an empty directory, pipenv always points to an existing environment although I'm not in that environment. Notice how it also creates the Pipfile in the directory where pipenv points to, instead of the current directory:

[philippbunke@fedora market_maker]$ pipenv --python 3.10
Virtualenv already exists!
Removing existing virtualenv...
Creating a virtualenv for this project...
Pipfile: /home/philippbunke/Programs/repos/work/playground/Pipfile
Using /usr/bin/python3 (3.10.6) to create virtualenv...
⠋ Creating virtual environment...created virtual environment CPython3.10.6.final.0-64 in 558ms
  creator CPython3Posix(dest=/home/philippbunke/.local/share/virtualenvs/playground-QFVQT-z1, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/philippbunke/.local/share/virtualenv)
    added seed packages: pip==21.3.1, setuptools==58.3.0, wheel==0.37.0
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment!
Virtualenv location: /home/philippbunke/.local/share/virtualenvs/playground-QFVQT-z1

Does anyone has an idea where this is coming from?

P.S.
When I try to install a package I get the following error:

[philippbunke@fedora market_maker]$ pipenv install qpsolvers
Installing qpsolvers...
Adding qpsolvers to Pipfile's [packages]...
✔ Installation Succeeded
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed!

CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement python>=3.6 (from versions: none)
[ResolutionFailure]:   File "/home/philippbunke/.local/lib/python3.10/site-packages/pipenv/resolver.py", line 743, in _main
[ResolutionFailure]:       resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
[ResolutionFailure]:   File "/home/philippbunke/.local/lib/python3.10/site-packages/pipenv/resolver.py", line 704, in resolve_packages
[ResolutionFailure]:       results, resolver = resolve(
[ResolutionFailure]:   File "/home/philippbunke/.local/lib/python3.10/site-packages/pipenv/resolver.py", line 685, in resolve
[ResolutionFailure]:       return resolve_deps(
[ResolutionFailure]:   File "/home/philippbunke/.local/lib/python3.10/site-packages/pipenv/utils.py", line 1370, in resolve_deps
[ResolutionFailure]:       results, hashes, markers_lookup, resolver, skipped = actually_resolve_deps(
[ResolutionFailure]:   File "/home/philippbunke/.local/lib/python3.10/site-packages/pipenv/utils.py", line 1099, in actually_resolve_deps
[ResolutionFailure]:       resolver.resolve()
[ResolutionFailure]:   File "/home/philippbunke/.local/lib/python3.10/site-packages/pipenv/utils.py", line 877, in resolve
[ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for python>=3.6


问:
How to allow headers with underscores in nginx within AWS Load Balancer
Inexplicably, nginx blocks HTTP header names which contain underscores, despite their being RFC compliant.

There is an nginx config to allow them (underscores_in_headers on; in server block of config), but its happening in the nginx instance within our AWS Load Balancer, which our DevOps says is not configurable.

Is there a workaround?


问:
Does 7z have options for efficiently extracting large numbers of files?
Using 7z to unzip a 50 GB file that contains about 600,000 files, the speed of extraction dramatically drops as the number of extracted files increases. It takes approximately 20 hours to unzip the entire batch.

I wrote a Linux script that runs in parallel to the 7z process. It moves unzipped files to another directory so that the 7z target directory never accumulates too many files. Doing this dropped the total time to about 30 minutes.

While this works, is there a better way to do this? Preferably built into 7z?

Running on Ubuntu 22.04.1 LTS

7-Zip [64] V16.02


问:
React-Native FLAG_IMMUTABLE or FLAG_MUTABLE
I'm trying to update the Android SDK version but after upgrading it from 30 to 31 it's throwing an error.

The error is:

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

Also, I have the following lines in the Logcat.

Some of my dependency versions are;

```<code>implementation "com.google.firebase:firebase-messaging:17.6.0"
implementation "com.google.firebase:firebase-core:16.0.8"
</code>```

I have local notifications in the application. Because of that, I'm using an older version of the firebase.

Also, I don't have any PendingIntent in the project. Some of my dependencies may be using it. I tried to use couple of solutions but none of them worked.

Thanks.

Body:
I'm trying to update the Android SDK version but after upgrading it from 30 to 31 it's throwing an error.

The error is:

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.

Also, I have the following lines in the Logcat.

Some of my dependency versions are;

implementation "com.google.firebase:firebase-messaging:17.6.0"
implementation "com.google.firebase:firebase-core:16.0.8"

I have local notifications in the application. Because of that, I'm using an older version of the firebase.

Also, I don't have any PendingIntent in the project. Some of my dependencies may be using it. I tried to use couple of solutions but none of them worked.

Thanks.


问:
Spark SQL select subset of fields of map column
We're processing data from different sources which all differ in structure, but yet have core common fields. For the sake of example:

```<code>root
 |-- sesionId: long (nullable = false)
 |-- region: string (nullable = true)
 |-- auctions: map (nullable = true)
 |    |-- key: long
 |    |-- value: struct (valueContainsNull = true)
 |    |    |-- requests: long (nullable = false)
 |    |    |-- wins: long (nullable = false)
 |    |    |-- malformed: long (nullable = false)
</code>```

and

```<code>root
 |-- sesionId: long (nullable = false)
 |-- datacenter: string (nullable = true)
 |-- trafficType: string (nullable = true)
 |-- auctions: map (nullable = true)
 |    |-- key: long
 |    |-- value: struct (valueContainsNull = true)
 |    |    |-- requests: long (nullable = false)
 |    |    |-- wins: long (nullable = false)
 |    |    |-- rejected: long (nullable = false)
 |    |    |-- monetized: long (nullable = false)
</code>```

Let's say, I want to aggregate core statistics regardless of input source.

```<code>case class CoreKpis(requests: Long, wins: Long)

class DummyMapAggregate[K, V](implicit E: Encoder[Map[K, V]])
  extends Aggregator[Map[K, V], Map[K, V], Map[K, V]] {
  def zero: Map[K, V] = Map.empty
  def reduce(buffer: Map[K, V], input: Map[K, V]): Map[K, V] = input
  def merge(buffer1: Map[K, V], buffer2: Map[K, V]): Map[K, V] = buffer2
  def finish(reduction: Map[K, V]): Map[K, V] = reduction
  def bufferEncoder: Encoder[Map[K, V]] = E
  def outputEncoder: Encoder[Map[K, V]] = E
}

val aggMap = udaf(new DummyMapAggregate[Long, CoreKpis]())

df.groupBy(col("sessionId")).agg(aggMap(col("auctions"))
</code>```

But I end up getting

```<code>org.apache.spark.sql.AnalysisException: cannot resolve 'DummyMapAggregate(auctions)'
due to data type mismatch: argument 1 requires map<bigint,struct<requests:bigint,wins:bigint>> type,
however, '`auctions`' is of map<bigint,struct<requests:bigint,wins:bigint,malformed:bigint>> type.
</code>```

The question is following: how to avoid this exception? Should I somehow cast the column to correct type first or what?

Body:
We're processing data from different sources which all differ in structure, but yet have core common fields. For the sake of example:

root
 |-- sesionId: long (nullable = false)
 |-- region: string (nullable = true)
 |-- auctions: map (nullable = true)
 |    |-- key: long
 |    |-- value: struct (valueContainsNull = true)
 |    |    |-- requests: long (nullable = false)
 |    |    |-- wins: long (nullable = false)
 |    |    |-- malformed: long (nullable = false)

and

root
 |-- sesionId: long (nullable = false)
 |-- datacenter: string (nullable = true)
 |-- trafficType: string (nullable = true)
 |-- auctions: map (nullable = true)
 |    |-- key: long
 |    |-- value: struct (valueContainsNull = true)
 |    |    |-- requests: long (nullable = false)
 |    |    |-- wins: long (nullable = false)
 |    |    |-- rejected: long (nullable = false)
 |    |    |-- monetized: long (nullable = false)

Let's say, I want to aggregate core statistics regardless of input source.

case class CoreKpis(requests: Long, wins: Long)

class DummyMapAggregate[K, V](implicit E: Encoder[Map[K, V]])
  extends Aggregator[Map[K, V], Map[K, V], Map[K, V]] {
  def zero: Map[K, V] = Map.empty
  def reduce(buffer: Map[K, V], input: Map[K, V]): Map[K, V] = input
  def merge(buffer1: Map[K, V], buffer2: Map[K, V]): Map[K, V] = buffer2
  def finish(reduction: Map[K, V]): Map[K, V] = reduction
  def bufferEncoder: Encoder[Map[K, V]] = E
  def outputEncoder: Encoder[Map[K, V]] = E
}

val aggMap = udaf(new DummyMapAggregate[Long, CoreKpis]())

df.groupBy(col("sessionId")).agg(aggMap(col("auctions"))

But I end up getting

org.apache.spark.sql.AnalysisException: cannot resolve 'DummyMapAggregate(auctions)'
due to data type mismatch: argument 1 requires map<bigint,struct<requests:bigint,wins:bigint>> type,
however, '`auctions`' is of map<bigint,struct<requests:bigint,wins:bigint,malformed:bigint>> type.

The question is following: how to avoid this exception? Should I somehow cast the column to correct type first or what?


问:
Why is PyAutoGUI not detecting specific cards in a card game
I'm trying to make a bot that automatically plays a card game for you. But it's for some reason only detecting the shuffle card and doesn't detect the other ones. My Code:

```<code>def locateandClick():
    oneheart = pyautogui.locateOnScreen('oneheart.png',  grayscale=False, confidence=0.6)
    tenheart = pyautogui.locateOnScreen('tenheart.png',  grayscale=False, confidence=0.6)
    shuffle = pyautogui.locateOnScreen('shuffle.png',  grayscale=False, confidence=0.6)

    if oneheart and tenheart:
        one = pyautogui.center(oneheart)
        ten = pyautogui.center(tenheart)
        pyautogui.moveTo(ten[0], ten[1])
        pyautogui.mouseDown()
        pyautogui.mouseUp()
        pyautogui.moveTo(one[0], one[1])
        pyautogui.mouseDown()
        pyautogui.mouseUp()

    if not oneheart and not tenheart and shuffle:
       shufflecenter = pyautogui.center(shuffle)
       pyautogui.moveTo(shufflecenter[0], shufflecenter[1])
       pyautogui.mouseDown()
       pyautogui.mouseUp()

while True:
    locateandClick()
</code>```

For some reason it only detects the shuffle card and doesn't detect any other card that I put in (yes I have openCV installed for confidence to work)

Shuffle image and oneheart and tenheart images:

Body:
I'm trying to make a bot that automatically plays a card game for you. But it's for some reason only detecting the shuffle card and doesn't detect the other ones. My Code:

def locateandClick():
    oneheart = pyautogui.locateOnScreen('oneheart.png',  grayscale=False, confidence=0.6)
    tenheart = pyautogui.locateOnScreen('tenheart.png',  grayscale=False, confidence=0.6)
    shuffle = pyautogui.locateOnScreen('shuffle.png',  grayscale=False, confidence=0.6)

    if oneheart and tenheart:
        one = pyautogui.center(oneheart)
        ten = pyautogui.center(tenheart)
        pyautogui.moveTo(ten[0], ten[1])
        pyautogui.mouseDown()
        pyautogui.mouseUp()
        pyautogui.moveTo(one[0], one[1])
        pyautogui.mouseDown()
        pyautogui.mouseUp()

    if not oneheart and not tenheart and shuffle:
       shufflecenter = pyautogui.center(shuffle)
       pyautogui.moveTo(shufflecenter[0], shufflecenter[1])
       pyautogui.mouseDown()
       pyautogui.mouseUp()

while True:
    locateandClick()

For some reason it only detects the shuffle card and doesn't detect any other card that I put in (yes I have openCV installed for confidence to work)

Shuffle image and oneheart and tenheart images:


问:
Selected idea name should show all its attributes in List box
I have created tables for the attributes (Country, Currency, RiskLevel, Invest_Type, Price)
all these are added into another table named IdeaDetails as foreign keys which i could use to display all the attributes when a specific idea is selected.

example how i display it:
Tech name - USA
- 20000
- DOLLARS
- Low Risk
- Start-up Type

I have used a Query which letThis Query adds the country from the Country table to the selected Idea name in windows form  me add the name of the idea and display the hard coded data in it. This images shows what the above query does

i wanted to know if there is a query where i could add the rest of the attributes like currency, riskLevel, invest type, price onto the same selected idea name.

Thank you.


问:
Call function on button click inside child component
I'm very new to Vuejs and I'm trying to call a function inside my component after a button is clicked but the function is not being called.

My project is a little complicated but to make this simpler I'll just write code for section I'm struggling with.

Parent.vue

```<code><template>
    <div class="row" is="someID>
        <div v-if="admin">
            <AdminUser/>
        </div>
        <div v-if="user">
            <GeneralUser/>
        </div>
    </div>
</template>
</code>```

Child.vue

```<code><template>
    <form>
        <div>
            <label></label>
            .
            .
            .
            <label></label>
        </div>
    </form>
    <button v-on:click="myFunction()">Save</button>
</template>

<script>
    export default{
        methods: {
            myFunction: async function(){
                console.log("I AM HERE")
            }
        }
    }
</script>
</code>```

So in this case the Parent vue renders the child vue on some condition (this part works) but now that this component is rendered in the parent vue I want to be able to call the function inside that component on button click. At the moment, upon clicking nothing is happening and I'm not sure why.

Body:
I'm very new to Vuejs and I'm trying to call a function inside my component after a button is clicked but the function is not being called.

My project is a little complicated but to make this simpler I'll just write code for section I'm struggling with.

Parent.vue

<template>

            <AdminUser/>

            <GeneralUser/>

</template>

Child.vue

<template>
    <form>

            .
            .
            .

    </form>
    <button v-on:click="myFunction()">Save</button>
</template>

So in this case the Parent vue renders the child vue on some condition (this part works) but now that this component is rendered in the parent vue I want to be able to call the function inside that component on button click. At the moment, upon clicking nothing is happening and I'm not sure why.


问:
Is there a way I could call an API which trigger a glue job from dbt?
I have models in dbt but I after dbt test, I want to trigger an API call which could kick-off my AWS glue job. Any suggestions for workaround on this?

Approaches tried:

Dbt —> fal script (which runs python code) —> py script could call glue job
Blocker: later found that they are not running Python on dbt Cloud, they are running it in Github actions

Dbt  —> Rest/POST API with on-run-end (hooker)  —> glue job
Blocker: can’t find any instance where API calls are done from dbt (we could call dbt jobs from API but not the other way around)

Dbt new table —> SNS —> lambda fn —> glue job


问:
failed in the execution of the ODCIINDEXDELETE routine during deletion of geodata
An error occurs while deleting geographic(mdsys.sdo_geometry) data with geoindex from table.

Oracle 11g.

The error is:

```<code>ORA-29876: failed in the execution of the ODCIINDEXDELETE routine
ORA-13209 Internal Error While Reading SDO_INDEX_METADATA
ORA-06512: at  "MDSYS.SDO_INDEX_METHOD_10I", line 720
ORA-06512: at  "MDSYS.SDO_INDEX_METHOD_10I", line 250
</code>```

Geospatial index is "VALID"
The owner of table is user "B", but deleting data occurs by the user "A".

The user "A" has privileges:

select, insert, delete on mdsys.SDO_GEOM_METADATA_TABLE

select, insert, delete on mdsys.all_sdo_index_metadata

create table, CREATE sequence,UNLIMITED TABLESPACE

select, insert, delete on all tables of user "B"

What other privileges does the user "A" need?

Deleting from tables without geoindex happens correctly.
If grant user "A" all privileges then deleting the geodata occurs correctly.

Body:
An error occurs while deleting geographic(mdsys.sdo_geometry) data with geoindex from table.

Oracle 11g.

The error is:

ORA-29876: failed in the execution of the ODCIINDEXDELETE routine
ORA-13209 Internal Error While Reading SDO_INDEX_METADATA
ORA-06512: at  "MDSYS.SDO_INDEX_METHOD_10I", line 720
ORA-06512: at  "MDSYS.SDO_INDEX_METHOD_10I", line 250

Geospatial index is "VALID"
The owner of table is user "B", but deleting data occurs by the user "A".

The user "A" has privileges:

select, insert, delete on mdsys.SDO_GEOM_METADATA_TABLE

select, insert, delete on mdsys.all_sdo_index_metadata

create table, CREATE sequence,UNLIMITED TABLESPACE

select, insert, delete on all tables of user "B"

What other privileges does the user "A" need?

Deleting from tables without geoindex happens correctly.
If grant user "A" all privileges then deleting the geodata occurs correctly.


问:
Script cant find ecCodes library
It seems i have succesfully installed ecCodes. At least if i run the selfcheck in the terminal i get the expected response.

If i run the sell script which is supposed to work with ecCodes it seems to cant find the commands though. This is the Response i get:

Does it matter in which Folder ecCodes is installed? Does someone know what my System is missing?

The Shell Script looks like this:

```<code>#!/bin/bash

GFS_DATE="20161120"
GFS_TIME="06"; # 00, 06, 12, 18
RES="1p00" # 0p25, 0p50 or 1p00
BBOX="leftlon=0&rightlon=360&toplat=90&bottomlat=-90"
LEVEL="lev_10_m_above_ground=on"
GFS_URL="http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_${RES}.pl?file=gfs.t${GFS_TIME}z.pgrb2.${RES}.f000&${LEVEL}&${BBOX}&dir=%2Fgfs.${GFS_DATE}${GFS_TIME}"

curl "${GFS_URL}&var_UGRD=on" -o utmp.grib
curl "${GFS_URL}&var_VGRD=on" -o vtmp.grib

grib_set -r -s packingType=grid_simple utmp.grib utmp.grib
grib_set -r -s packingType=grid_simple vtmp.grib vtmp.grib

printf "{\"u\":`grib_dump -j utmp.grib`,\"v\":`grib_dump -j vtmp.grib`}" > tmp.json

rm utmp.grib vtmp.grib

DIR="c:\\Users\My Name\Documents\CGTutorial\CGTutorial - Minimal"
node ${DIR}/prepare.js ${1}/${GFS_DATE}${GFS_TIME}

rm tmp.json
</code>```

Title: Script cant find ecCodes library

Body:
It seems i have succesfully installed ecCodes. At least if i run the selfcheck in the terminal i get the expected response.

If i run the sell script which is supposed to work with ecCodes it seems to cant find the commands though. This is the Response i get:

Does it matter in which Folder ecCodes is installed? Does someone know what my System is missing?

The Shell Script looks like this:

#!/bin/bash

GFS_DATE="20161120"
GFS_TIME="06"; # 00, 06, 12, 18
RES="1p00" # 0p25, 0p50 or 1p00
BBOX="leftlon=0&rightlon=360&toplat=90&bottomlat=-90"
LEVEL="lev_10_m_above_ground=on"
GFS_URL="http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_${RES}.pl?file=gfs.t${GFS_TIME}z.pgrb2.${RES}.f000&${LEVEL}&${BBOX}&dir=%2Fgfs.${GFS_DATE}${GFS_TIME}"

curl "${GFS_URL}&var_UGRD=on" -o utmp.grib
curl "${GFS_URL}&var_VGRD=on" -o vtmp.grib

grib_set -r -s packingType=grid_simple utmp.grib utmp.grib
grib_set -r -s packingType=grid_simple vtmp.grib vtmp.grib

printf "{\"u\":`grib_dump -j utmp.grib`,\"v\":`grib_dump -j vtmp.grib`}" > tmp.json

rm utmp.grib vtmp.grib

DIR="c:\\Users\My Name\Documents\CGTutorial\CGTutorial - Minimal"
node ${DIR}/prepare.js ${1}/${GFS_DATE}${GFS_TIME}

rm tmp.json


问:
Canary release in IOT scenario
i have use case for doing canary releases on a consumer basis in a IOT setup, for example lets says i am consuming IOT data feed from a 100 houses and provide the ability to turn on/ off appliances using a mobile app. Now what am looking to do is when i develop a new feature for example i automatically dispatch a problem ticket to the service provider if a heater is malfunctioning, i would want to the able to enable this only houses 1 to 10. Could someone please help me how i would be able to solve this issue?</p>

Title: Canary release in IOT scenario


问:
ROR Self Join for self reference
I am using the Self Joins to add reference to its own table.

```<code>class Employee < ApplicationRecord
  belongs_to :manager, class_name: "Employee", optional: true
  has_many :customers
end

class Customer
  belongs_to :employee
end
</code>```

I am fetching the employee data based. One employee will have one employee_head and employee_head will have a boss.

In the serializer i have

```<code>class EmployeeSerializer < ApplicationSerializer
  # include FastJsonapi::ObjectSerializer
  attributes :id, :name, :manager

  def manager
    ActiveModel::SerializableResource.new(object.manager)
  end
end
</code>```

when i query form employee, i am expecting:

```<code>{
   employee:
      {
           id: 1,
           name: "employee name",
           customer_attributes: [
              { id: 8, name: customer_name }
           ],
           manager: {
                id: 2,
                name: "employee head name",
                customer_attributes: [
                   { id: 8, name: customer_name }
                ],
                manager: {
                     id: 3,
                     name: "boss name",
                     customer_attributes: [
                          { id: 8, name: customer_name }
                     ],
                }
            }
      }
}
</code>```

I am getting the expected data using:

```<code>Employee.includes(:customers).where(name: "employee name", employee_type: employee)
</code>```

but the problem is when i hit the query, the customer information is fetched from the database multiple time. I am confuse where to use includes to avoid N+1 query to DB.

Thanks in advance

Title: ROR Self Join for self reference

Body:
I am using the Self Joins to add reference to its own table.

class Employee < ApplicationRecord
  belongs_to :manager, class_name: "Employee", optional: true
  has_many :customers
end

class Customer
  belongs_to :employee
end

I am fetching the employee data based. One employee will have one employee_head and employee_head will have a boss.

In the serializer i have

class EmployeeSerializer < ApplicationSerializer
  # include FastJsonapi::ObjectSerializer
  attributes :id, :name, :manager

  def manager
    ActiveModel::SerializableResource.new(object.manager)
  end
end

when i query form employee, i am expecting:

{
   employee:
      {
           id: 1,
           name: "employee name",
           customer_attributes: [
              { id: 8, name: customer_name }
           ],
           manager: {
                id: 2,
                name: "employee head name",
                customer_attributes: [
                   { id: 8, name: customer_name }
                ],
                manager: {
                     id: 3,
                     name: "boss name",
                     customer_attributes: [
                          { id: 8, name: customer_name }
                     ],
                }
            }
      }
}

I am getting the expected data using:

Employee.includes(:customers).where(name: "employee name", employee_type: employee)

but the problem is when i hit the query, the customer information is fetched from the database multiple time. I am confuse where to use includes to avoid N+1 query to DB.

Thanks in advance


问:
React Testing Library toBeInTheDocument failing despite being in the DOM
I have a test which basically contains the following code:

    const row = await screen.findByText('Test Subject');

    try {
      expect(row).toBeInTheDocument();
    } catch (e) {
      screen.debug();
      throw e;
    }
```
<p>The debug is for trying to track this down. <code>findByText</code> succeeds, and does find the element. I can log this out, and it appears. But when I do the expect, it fails <strong>SOMETIMES</strong>. It's unpredictable. I'm pretty certain the DOM isn't changing between calls, as I have logs out on every render and nothing logs out between the find and the assert.</p>
<p>I won't print the whole DOM tree, but on the catch debug, I can clearly see the row.</p>
<pre class="lang-html prettyprint-override"><code><tr
                  class="sc-jgrIVw bDPrDC"
                >
                  <td
                    class="sc-jeqYYF hinrdE"
                  >
                    <div
                      class="sc-clIAKW jvtlES"
                    >
                      05-Dec-2022 12:08
                    </div>
                  </td>
                  <td
                    class="sc-jeqYYF ijUrhn"
                  >
                    <div
                      class="sc-clIAKW jvtlES"
                    >
                      <div
                        title="Test"
                      >
                        Test
                      </div>
                    </div>
                  </td>
                  <td
                    class="sc-jeqYYF ijUrhn"
                  >
                    <div
                      class="sc-clIAKW jvtlES"
                    >
                      Test Subject
                    </div>
                  </td>
                </tr>
</code>```

So as far as I can tell, RTL knows my DOM is there, the DOM log shows its there, but toBeInTheDocument throws. What could I be missing?

Body:
I have a test which basically contains the following code:

    const row = await screen.findByText('Test Subject');

    try {
      expect(row).toBeInTheDocument();
    } catch (e) {
      screen.debug();
      throw e;
    }

The debug is for trying to track this down. findByText succeeds, and does find the element. I can log this out, and it appears. But when I do the expect, it fails SOMETIMES. It's unpredictable. I'm pretty certain the DOM isn't changing between calls, as I have logs out on every render and nothing logs out between the find and the assert.

I won't print the whole DOM tree, but on the catch debug, I can clearly see the row.

                      05-Dec-2022 12:08

                        Test

                      Test Subject

So as far as I can tell, RTL knows my DOM is there, the DOM log shows its there, but toBeInTheDocument throws. What could I be missing?


问:
How to Type A Generic List of objects? Each object includes a different Redux Action and Selector

I need to iterate through a list of CHAT_SETTINGS and render a SelectComponent for each item.

```<code>function ParentComponent(){

    const CHAT_SETTINGS = [
        {
            title: 'order',
            choices: ['recent', 'aToZ'],
            selector: orderSelector,
            action: setOrderAction,
        },
        {
            title: 'display',
            choices: ['comfortable', 'compact'],
            selector: displaySelector,
            action: setDisplayAction,
        },
    ];

    return (
        <div>
            {CHAT_SETTINGS.map(setting => <SelectComponent {...setting} />)}
        </div>
    );
}
</code>```

The SelectComponent looks more or less like this:

```<code>interface Props<T> {
    title: string;
    selector: (state: Store) => T;
    action: ActionCreatorWithPayload<T, string>;
    choices?: T[];
}

function SelectComponent<T>({ title, choices, selector, action }: Props<T>) {
    const value = useSelector(selector);
    const dispatch = useDispatch();

    return (
        <select
            value={value}
            onChange={(e) => {
                dispatch(action(e.target.value));
            }}
        >
            {choices.map((choice) => (
                <option key={String(choice)} value={String(choice)}>
                    {title}
                </option>
            ))}
        </select>
    );
}
</code>```

✏ A Redux Selector and a Redux Action needs to be passed in via props.

These Selectors/Actions have the following types:

```<code>displaySelector: (state: Store) => 'comfortable' | 'compact'
setDisplayAction: ActionCreatorWithPayload<'comfortable' | 'compact', string>

orderSelector: (state: Store) => 'recent' | 'aToZ'
setOrderAction: ActionCreatorWithPayload<'recent' | 'aToZ', string>

</code>```

So far I was able to come up with something like this...

```<code>type ChatSettingItem<T> = {
    title: string;
    choices: T[];
    selector: (state: Store) => T;
    action: ActionCreatorWithPayload<T, string>
}

const CHAT_SETTINGS: ChatSettingItem<
   ReturnType<typeof orderSelector> | ReturnType<typeof displaySelector>
>[] = [ ... ];
</code>```

However, typescript keeps complaining about my actions, it says:

Type 'ActionCreatorWithPayload<"expanded" | "collapsed", string>' is not assignable to type 'ActionCreatorWithPayload<"recent" | "aToZ" | "expanded" | "collapsed", string>'.

Types of parameters 'payload' and 'payload' are incompatible.

Type '"recent" | "aToZ" | "expanded" | "collapsed"' is not assignable to type '"expanded" | "collapsed"'.

❓My question is: How can I have type-safety in this scenario?

Body:
I need to iterate through a list of CHAT_SETTINGS and render a SelectComponent for each item.

function ParentComponent(){

    const CHAT_SETTINGS = [
        {
            title: 'order',
            choices: ['recent', 'aToZ'],
            selector: orderSelector,
            action: setOrderAction,
        },
        {
            title: 'display',
            choices: ['comfortable', 'compact'],
            selector: displaySelector,
            action: setDisplayAction,
        },
    ];

    return (

            {CHAT_SETTINGS.map(setting => <SelectComponent {...setting} />)}

    );
}

The SelectComponent looks more or less like this:

interface Props<T> {
    title: string;
    selector: (state: Store) => T;
    action: ActionCreatorWithPayload<T, string>;
    choices?: T[];
}

function SelectComponent<T>({ title, choices, selector, action }: Props<T>) {
    const value = useSelector(selector);
    const dispatch = useDispatch();

    return (
        <select
            value={value}
            onChange={(e) => {
                dispatch(action(e.target.value));
            }}
        >
            {choices.map((choice) => (
                <option key={String(choice)} value={String(choice)}>
                    {title}
                </option>
            ))}
        </select>
    );
}

✏ A Redux Selector and a Redux Action needs to be passed in via props.

These Selectors/Actions have the following types:

displaySelector: (state: Store) => 'comfortable' | 'compact'
setDisplayAction: ActionCreatorWithPayload<'comfortable' | 'compact', string>

orderSelector: (state: Store) => 'recent' | 'aToZ'
setOrderAction: ActionCreatorWithPayload<'recent' | 'aToZ', string>

So far I was able to come up with something like this...

type ChatSettingItem<T> = {
    title: string;
    choices: T[];
    selector: (state: Store) => T;
    action: ActionCreatorWithPayload<T, string>
}

const CHAT_SETTINGS: ChatSettingItem<
   ReturnType<typeof orderSelector> | ReturnType<typeof displaySelector>
>[] = [ ... ];

However, typescript keeps complaining about my actions, it says:

Type 'ActionCreatorWithPayload<"expanded" | "collapsed", string>' is not assignable to type 'ActionCreatorWithPayload<"recent" | "aToZ" | "expanded" | "collapsed", string>'.

Types of parameters 'payload' and 'payload' are incompatible.

Type '"recent" | "aToZ" | "expanded" | "collapsed"' is not assignable to type '"expanded" | "collapsed"'.

❓My question is: How can I have type-safety in this scenario?


问:
Can path- statement- and branch coverage say anything about each other?
I had the following question the other day (from an old exam test):

"If we in regard to code coverage have a statement coverage of 80% then that means:

branch coverage >= 80% but can't say anything about path coverage

path coverage >= 80% but we can't say anything about branch coverage

branch coverage < 80% and path coverage < 80%

You can't say anything about path- and branch coverage

branch coverage >= 80% and path coverage >= 80% "

Now, I would say that if you have statement coverage of 80%, then you can't say anything about path coverage nor branch coverage. Also, that if the question was about branch coverage or if it was about path coverage, then you would also not be able to saying anything i regards to the other two.

Although, if you had 100% statement coverage, then you know that you have 100% branch coverage, and that if you had 100% path coverage, then you would have 100% branch- and statement coverage.

Is this right?

I tried running some code in IntelliJ and see if I could figure something out, but I'm a little lost.


问:
how can i get database instance in another kotlin class based on my main database class
In my project, I use the Singleton design pattern, add a companion object and a function that returns a database object instance. This will avoid creating multiple instances
database object through which the connection to the SQL server is established.

I have the following code to connect to the database:

```<code>// Annotates class to be a Room Database with a table (entity) of the Word class
@Database(entities = arrayOf(ShoppingList::class), version = 1, exportSchema = false)
public abstract class ShoppingListRoomDatabase : RoomDatabase() {
    abstract fun shoppingListDao(): ShoppingListDao

    companion object {
        // Singleton prevents multiple instances of database opening at the
        // same time.
        @Volatile
        public var INSTANCE: ShoppingListRoomDatabase? = null

        fun getDatabase(context: Context, scope: CoroutineScope): ShoppingListRoomDatabase {
            // if the INSTANCE is not null, then return it,
            // if it is, then create the database
            return INSTANCE ?: synchronized(this) {
                val instance = Room.databaseBuilder(
                    context.applicationContext,
                    ShoppingListRoomDatabase::class.java,
                    "shopping_list_database"
                ).addCallback(ShoppingListDatabaseCallback(scope)).build()
                INSTANCE = instance
                // return instance
                instance
            }
        }
    }
}

private class ShoppingListDatabaseCallback(
    private val scope: CoroutineScope
) : RoomDatabase.Callback() {
    override fun onCreate(db: SupportSQLiteDatabase) {
        super.onCreate(db)
        ShoppingListRoomDatabase.INSTANCE?.let { database ->
            scope.launch {
                populateDatabase(database.shoppingListDao())
            }
        }
    }
    fun populateDatabase(shoppingListDao: ShoppingListDao) {
        shoppingListDao.deleteAll()
        var shoppingList = ShoppingList(1,"First List")
        shoppingListDao.insert(shoppingList)
        shoppingList = ShoppingList(2, "Second List!")
        shoppingListDao.insert(shoppingList)
    }
}
</code>```

Interface:

```<code>@Dao
interface ShoppingListDao {
    @Query("SELECT * FROM shopping_lists ORDER BY id ASC")
    fun getOrderedShoppingLists(): Flow<List<ShoppingList>>
    @Insert
    fun insert(shoppingList: ShoppingList)
    @Query("DELETE FROM shopping_lists")
    fun deleteAll()
}
</code>```

How can I get this database instance in another kotlin class to work with it?

Body:
In my project, I use the Singleton design pattern, add a companion object and a function that returns a database object instance. This will avoid creating multiple instances
database object through which the connection to the SQL server is established.

I have the following code to connect to the database:

// Annotates class to be a Room Database with a table (entity) of the Word class
@Database(entities = arrayOf(ShoppingList::class), version = 1, exportSchema = false)
public abstract class ShoppingListRoomDatabase : RoomDatabase() {
    abstract fun shoppingListDao(): ShoppingListDao

    companion object {
        // Singleton prevents multiple instances of database opening at the
        // same time.
        @Volatile
        public var INSTANCE: ShoppingListRoomDatabase? = null

        fun getDatabase(context: Context, scope: CoroutineScope): ShoppingListRoomDatabase {
            // if the INSTANCE is not null, then return it,
            // if it is, then create the database
            return INSTANCE ?: synchronized(this) {
                val instance = Room.databaseBuilder(
                    context.applicationContext,
                    ShoppingListRoomDatabase::class.java,
                    "shopping_list_database"
                ).addCallback(ShoppingListDatabaseCallback(scope)).build()
                INSTANCE = instance
                // return instance
                instance
            }
        }
    }
}

private class ShoppingListDatabaseCallback(
    private val scope: CoroutineScope
) : RoomDatabase.Callback() {
    override fun onCreate(db: SupportSQLiteDatabase) {
        super.onCreate(db)
        ShoppingListRoomDatabase.INSTANCE?.let { database ->
            scope.launch {
                populateDatabase(database.shoppingListDao())
            }
        }
    }
    fun populateDatabase(shoppingListDao: ShoppingListDao) {
        shoppingListDao.deleteAll()
        var shoppingList = ShoppingList(1,"First List")
        shoppingListDao.insert(shoppingList)
        shoppingList = ShoppingList(2, "Second List!")
        shoppingListDao.insert(shoppingList)
    }
}

Interface:

@Dao
interface ShoppingListDao {
    @Query("SELECT * FROM shopping_lists ORDER BY id ASC")
    fun getOrderedShoppingLists(): Flow<List<ShoppingList>>
    @Insert
    fun insert(shoppingList: ShoppingList)
    @Query("DELETE FROM shopping_lists")
    fun deleteAll()
}

How can I get this database instance in another kotlin class to work with it?


问:
Function printing twice when i call it
im trying to refresh the HUD of my game by calling the function hud() everytime that a data changes, but it shows twice the information:

```<code>def hud(nickname):
    os.system('cls')

    global rodada
    rodada += 1

    print(f'\033[33mRodada\033[m: {rodada}')

    print(f'\033[92m{nickname}\033[m: {pontos_jogador_total} | \033[92mComputador\033[m: {pontos_computador_total}')

    # Opção de ajuda com manilhas
    if modo_ajuda_manilhas == False:
        print(f'\033[91mVira\033[m: {vira[0]}')
    else:
        for i in baralho_check:
            if vira[0] in i:
                print(f'\033[91mVira\033[m: {vira[0]} | \033[91mTodas manilhas\033[m: ', end='')
                for i in baralho_check[baralho_check.index(i)]:
                    print(f'{i}', end=' ')

    if ver_cartas_adversario:
        print("\n\033[33mMão computador:\033[m")
        for i in cartas_mao_computador:
            print(f'| {i}', end=' | ')

    # Mostrar as cartas na mesa
    if len(cartas_na_mesa) == 0:
        print(f'\n\n\033[91mMesa\033[m:\n|   | |   |')
    else:
        print(f'\n\n\033[91mMesa\033[m:')
        for i in cartas_na_mesa:
            print(f'| {i}', end=' | ')

    # Mostrar mão Jogador
    print(f'\n\033[92mSua mão\033[m:')
    for i in cartas_mao_jogador:
        print(f'| {i}', end=' | ')

começar_novo_jogo() -> starts a new game function
distribuir_cartas() -> give the cards to the players function
hud(nickname) -> HUD funcion and the parameter nickname given to it
jogador_joga(1) -> trowing my first card in my hand to the table (mesa)
hud(nickname) ->  refreshing the HUD to show 1 less card in my hand (mão) and 1 more card in the table (mesa)
</code>```

output:

```<code>| 4 ♦ | | 4 ♠ | | 5 ♥ | Rodada: 2
Gustavo: 0 | Computador: 0
Vira: 2 ♥

Mesa:
| 4 ♦ |
Sua mão:
| 4 ♠ | | 5 ♥ |
</code>```

my problem:

```<code>| 4 ♦ | | 4 ♠ | | 5 ♥ | Rodada: 2 <--- here, i just want to show the "Rodada: 2" and not my "cards" at the top of my HUD
</code>```

i think the problem is that im calling the function HUD twice, but how can i refesh the HUD whitout showing my cards at the top?

images that can help:
Code printscreen

Output printscreen

Title: Function printing twice when i call it

Body:
im trying to refresh the HUD of my game by calling the function hud() everytime that a data changes, but it shows twice the information:

def hud(nickname):
    os.system('cls')

    global rodada
    rodada += 1

    print(f'\033[33mRodada\033[m: {rodada}')

    print(f'\033[92m{nickname}\033[m: {pontos_jogador_total} | \033[92mComputador\033[m: {pontos_computador_total}')

    # Opção de ajuda com manilhas
    if modo_ajuda_manilhas == False:
        print(f'\033[91mVira\033[m: {vira[0]}')
    else:
        for i in baralho_check:
            if vira[0] in i:
                print(f'\033[91mVira\033[m: {vira[0]} | \033[91mTodas manilhas\033[m: ', end='')
                for i in baralho_check[baralho_check.index(i)]:
                    print(f'{i}', end=' ')

    if ver_cartas_adversario:
        print("\n\033[33mMão computador:\033[m")
        for i in cartas_mao_computador:
            print(f'| {i}', end=' | ')

    # Mostrar as cartas na mesa
    if len(cartas_na_mesa) == 0:
        print(f'\n\n\033[91mMesa\033[m:\n|   | |   |')
    else:
        print(f'\n\n\033[91mMesa\033[m:')
        for i in cartas_na_mesa:
            print(f'| {i}', end=' | ')

    # Mostrar mão Jogador
    print(f'\n\033[92mSua mão\033[m:')
    for i in cartas_mao_jogador:
        print(f'| {i}', end=' | ')

começar_novo_jogo() -> starts a new game function
distribuir_cartas() -> give the cards to the players function
hud(nickname) -> HUD funcion and the parameter nickname given to it
jogador_joga(1) -> trowing my first card in my hand to the table (mesa)
hud(nickname) ->  refreshing the HUD to show 1 less card in my hand (mão) and 1 more card in the table (mesa)

output:

| 4 ♦ | | 4 ♠ | | 5 ♥ | Rodada: 2
Gustavo: 0 | Computador: 0
Vira: 2 ♥

Mesa:
| 4 ♦ |
Sua mão:
| 4 ♠ | | 5 ♥ |

my problem:

| 4 ♦ | | 4 ♠ | | 5 ♥ | Rodada: 2 <--- here, i just want to show the "Rodada: 2" and not my "cards" at the top of my HUD

i think the problem is that im calling the function HUD twice, but how can i refesh the HUD whitout showing my cards at the top?

images that can help:
Code printscreen

Output printscreen


问:
Python - Numpy_Financial fv() previous value in function
I'm using Numpy_Financial to get a future value of an investment.

```<code>Npf.fv(rate, nper, pmt, pv, when='end
</code>```

If I have x =[0,1,2,3,4,5]
y = fv(rate, x, pmt, pv,  'end')

Is it possible to rewrite that to

```<code>Y = fv(rate, if x<=0: 0 else 1, pmt, if x<=0: pv else y(i-1), 'end')
</code>```

I'm trying to rewrite it so that I can alter the pmt between certain x values.

Thanks

I tried the above and got a syntax error.
It works fine written in the first format but if you vary the pmt for say x=5 the end result is as if the varied pmt was taken for all 5 compounding periods for this element of x.

Body:
I'm using Numpy_Financial to get a future value of an investment.

Npf.fv(rate, nper, pmt, pv, when='end

If I have x =[0,1,2,3,4,5]
y = fv(rate, x, pmt, pv,  'end')

Is it possible to rewrite that to

Y = fv(rate, if x<=0: 0 else 1, pmt, if x<=0: pv else y(i-1), 'end')

I'm trying to rewrite it so that I can alter the pmt between certain x values.

Thanks

I tried the above and got a syntax error.
It works fine written in the first format but if you vary the pmt for say x=5 the end result is as if the varied pmt was taken for all 5 compounding periods for this element of x.


问:
How to structure a python module to call a single class or function by with "import some_module" rather than "import some_module.desired_object"?
This feels either incredibly basic or impossible for good reason, but my inability to simplify things this way really discourages me from some practices that would otherwise make my code more modular or maintainable, so it would really benefit me if possible.

As I stated in the question, if I write a module to execute a single function or be a single class, I would really like to simply call that module rather than module.object().  Often there is a lot going on under the hood and it's more maintainable to create a more elaborate file structure to organize the scripts being called, but once the module is called it only achieves a single function so it just feels silly to "from the_module import the_only_generally_useful_bit" rather than saying "import the_module" and having "the_module()" execute the_only_generally_useful_bit.  I know this feels like a silly nitpick, and it's generally better to be more explicit, also for maintainability, but this is a simplified example.

Here is some simplified example code:

inside my_module.py:

```<code>from tools import organize_thing, do_thing

def the_only_generally_useful_bit(arg):
    data = organize_thing(arg)
    desired_thing = do_thing(data)
    return desired_thing

</code>```

To utilise the_only_generally_useful_bit I'd need to:

```<code>from my_module import the_only_generally_useful_bit

desired_thing = the_only_generally_useful_bit(arg)
</code>```

and I wonder if there is a way to change file structure or add add some  boilerplate so that I could simply:

```<code>import my_module

desired_thing = my_module(args)
</code>```

Body:
This feels either incredibly basic or impossible for good reason, but my inability to simplify things this way really discourages me from some practices that would otherwise make my code more modular or maintainable, so it would really benefit me if possible.

As I stated in the question, if I write a module to execute a single function or be a single class, I would really like to simply call that module rather than module.object().  Often there is a lot going on under the hood and it's more maintainable to create a more elaborate file structure to organize the scripts being called, but once the module is called it only achieves a single function so it just feels silly to "from the_module import the_only_generally_useful_bit" rather than saying "import the_module" and having "the_module()" execute the_only_generally_useful_bit.  I know this feels like a silly nitpick, and it's generally better to be more explicit, also for maintainability, but this is a simplified example.

Here is some simplified example code:

inside my_module.py:

from tools import organize_thing, do_thing

def the_only_generally_useful_bit(arg):
    data = organize_thing(arg)
    desired_thing = do_thing(data)
    return desired_thing

To utilise the_only_generally_useful_bit I'd need to:

from my_module import the_only_generally_useful_bit

desired_thing = the_only_generally_useful_bit(arg)

and I wonder if there is a way to change file structure or add add some  boilerplate so that I could simply:

import my_module

desired_thing = my_module(args)


问:
Android-Car Media-App onPlayFromSearch not called in most cases
I want to enable voice commands.

When i say 'play next station' -> ok onSkipToNext(...) is called

When i say 'play previous station' -> ok onSkipToPrevious(...) is called

When i say 'play blubber' (something undefined) -> ok onPlayFromSearch(...) is called

When i say 'play NDR 2' (a really existing radio station) -> nothing called in my app, but google say 'therefore you need to install tunein ....'

tuneis is a competitor to us.... what is going on?

I have no idea what todo... i would expect onPlayFromSearch will be called
everytime i say something like 'play ...'