问:
How to get SvelteKit forms working in Vercel/Netlify/etc
I'm pretty new to Svelte but it is nice and straightforward in general with this form submission I have spent hours and it is driving me crazy as it doesn't make any sense why it is not sometimes working in Vercel.

I created a separate minimal SvelteKit project that submits the form to this webhook.site endpoint and it works perfectly in localhost but in Vercel deployment it works sometimes. Works once, then doesn't work three times, ten works four times in a row, then doesn't work again. Random. Sometimes Vercel gives an error, sometimes not. Here's the error:

```<code>[POST] /?/create
22:12:29:53
TypeError: fetch failed
    at fetch (/var/task/node_modules/undici/index.js:105:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (/var/task/node_modules/undici/lib/core/connect.js:176:24)
      at /var/task/node_modules/undici/lib/core/connect.js:123:46
      at Immediate._onImmediate (/var/task/node_modules/undici/lib/core/connect.js:164:9)
      at process.processImmediate (node:internal/timers:471:21) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}
</code>```

Then, without doing anything I tested again and it was working like 20 times in a row. I left it like that and came back after ~1h and it was still working like 10 times per row. I was here.

Then I decided to start experimenting again and in the next commit I removed the header authentication that isn't needed for the webhook.site but I had it there because, during the endless hours of hassling with it, I got at some point "feeling" that if the not used HASURA_ADMIN_SECRET ENV variable is there then it works more often. I know it is nonsense. It stopped working for good. Tested at least 20+ times with some breaks to be sure. Also tried multiple other endpoints that work brilliantly from a simple PHP script I created, from reqbin.com or from Postman. I have tried everything.

Allright, then I thought I was right - that magical HASURA_ADMIN_SECRET is needed so I added it back. That didn't fix the issue. Tried dozen of times and then although I made sure I added that header auth back properly I decided also to roll back to the version where it was stable working for so long as seen here. Now even that doesn't work anymore.

I tried long ago to deploy to Netlify and CloudFare, too as I suspected it is Netlify issue but I failed to even get the site working. So I decided to spend more time on getting it working in Netlify and when I got it working I got exactly the same error as in Netlify https://i.imgur.com/repNxyf.png so here's my dead end.

(I will make this post shorter once I get sorted)

Body:
I'm pretty new to Svelte but it is nice and straightforward in general with this form submission I have spent hours and it is driving me crazy as it doesn't make any sense why it is not sometimes working in Vercel.

I created a separate minimal SvelteKit project that submits the form to this webhook.site endpoint and it works perfectly in localhost but in Vercel deployment it works sometimes. Works once, then doesn't work three times, ten works four times in a row, then doesn't work again. Random. Sometimes Vercel gives an error, sometimes not. Here's the error:

[POST] /?/create
22:12:29:53
TypeError: fetch failed
    at fetch (/var/task/node_modules/undici/index.js:105:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  cause: ConnectTimeoutError: Connect Timeout Error
      at onConnectTimeout (/var/task/node_modules/undici/lib/core/connect.js:176:24)
      at /var/task/node_modules/undici/lib/core/connect.js:123:46
      at Immediate._onImmediate (/var/task/node_modules/undici/lib/core/connect.js:164:9)
      at process.processImmediate (node:internal/timers:471:21) {
    code: 'UND_ERR_CONNECT_TIMEOUT'
  }
}

Then, without doing anything I tested again and it was working like 20 times in a row. I left it like that and came back after ~1h and it was still working like 10 times per row. I was here.

Then I decided to start experimenting again and in the next commit I removed the header authentication that isn't needed for the webhook.site but I had it there because, during the endless hours of hassling with it, I got at some point "feeling" that if the not used HASURA_ADMIN_SECRET ENV variable is there then it works more often. I know it is nonsense. It stopped working for good. Tested at least 20+ times with some breaks to be sure. Also tried multiple other endpoints that work brilliantly from a simple PHP script I created, from reqbin.com or from Postman. I have tried everything.

Allright, then I thought I was right - that magical HASURA_ADMIN_SECRET is needed so I added it back. That didn't fix the issue. Tried dozen of times and then although I made sure I added that header auth back properly I decided also to roll back to the version where it was stable working for so long as seen here. Now even that doesn't work anymore.

I tried long ago to deploy to Netlify and CloudFare, too as I suspected it is Netlify issue but I failed to even get the site working. So I decided to spend more time on getting it working in Netlify and when I got it working I got exactly the same error as in Netlify https://i.imgur.com/repNxyf.png so here's my dead end.

(I will make this post shorter once I get sorted)


来源: stackexchange

问:
download a file from a url with a blob and token
I am consuming an API from Angular that returns a JSON with a key where a blob type url comes from which contains a file of type .xlsx (excel)

When executing my function, it returns the following error: Unexpected token P in JSON at position 0

my code is the following

this is my code in component.html

```<code><button
    pButton
    type="button"
    label="Descargar"
    icon="pi pi-download"
    class="p-button-secondary p-button-sm"
    (click)="download()"
>
</button>
</code>```

This is my code in my component.ts

Here I am using a library called file-saver

```<code>download() {

    this.downloadService.downloadFile('http://localhost:8080/b1s/v2/getItems/excel/download')
      .subscribe((resp: any) => {
        console.log(resp);
        var blob = new Blob(resp, {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
        saveAs(blob, "fileTests.xlsx");
      })
    }
</code>```

And this is my code in my service.ts

```<code>downloadFile(url: string) {
    let token = localStorage.getItem('token')
    return this.http.get(url, {
      headers: {
        'Authorization': 'Bearer ' + token,
        responseType: 'blob'
      }
    })
  }
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I am consuming an API from Angular that returns a JSON with a key where a blob type url comes from which contains a file of type .xlsx (excel)

When executing my function, it returns the following error: Unexpected token P in JSON at position 0

my code is the following

this is my code in component.html

<button
    pButton
    type="button"
    label="Descargar"
    icon="pi pi-download"
    class="p-button-secondary p-button-sm"
    (click)="download()"
>
</button>

This is my code in my component.ts

Here I am using a library called file-saver

download() {

    this.downloadService.downloadFile('http://localhost:8080/b1s/v2/getItems/excel/download')
      .subscribe((resp: any) => {
        console.log(resp);
        var blob = new Blob(resp, {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
        saveAs(blob, "fileTests.xlsx");
      })
    }

And this is my code in my service.ts

downloadFile(url: string) {
    let token = localStorage.getItem('token')
    return this.http.get(url, {
      headers: {
        'Authorization': 'Bearer ' + token,
        responseType: 'blob'
      }
    })
  }


问:
S3 trigger to perform a file conversion for a multi-part file type
I am working on converting shapefiles to geojson. Shapefiles are composed of at least 3 required files and as many as 8 separate files all residing in a folder.  To convert to geojson you need all the constituent parts. Right now I have a batch conversion process that goes through all the shapefiles stored in an s3 bucket, downloads all the separate file parts and performs the conversion.  What I'm trying to figure out now is how to run the file conversion process based on the upload of a single shapefile folder, hopefully using an s3 bucket trigger.

I have reviewed this answer (AWS - want to upload multiple files to S3 and only when all are uploaded trigger a lambda function) but in my case there is no frontend client (the answer presented in that question appears to be to signal a final event, but that is done from the client interface).  Maybe I need to build one, but I was trying to handle this only in the backend (there is no frontend and no plans to have one).  The 'user' would be dropping the files right into s3 directly without a file upload interface.

Of course when someone uploads a folder with all the shapefile parts in it, it triggers the s3 trigger for each part but each part cannot produce a shapefile alone.

A few solutions I thought of but with their own problems:

I am converting the shapefiles to geojson and storing the geojson in a separate s3 bucket using a naming convention for the geojson based on the s3 file name.  In theory you could always check if the geojson exists in the destination s3 bucket already and if not, run the conversion.  But this still doesn't take care of the timing aspect of all the multiple parts of the file being uploaded. I could check the name but it would be triggered multiple times, fail on some and then ultimately (probably) succeed after all the parts are in place.

1a. Maybe some type of try/except error checking on the conversion mentioned above? meaning, for each file part uploaded, go ahead and try to download and convert. This seems fragile and potentially error prone. Also, I believe that a certain subset of all the files will likely produce a geojson without error but without all the metadata or complete set of data so a successful conversion may not actually be a success.

Using a database to track which files have been converted, which would basically be the same solution as 1 above.

Partly a question as a solution: on the s3 web console there is 'file' upload and 'folder' upload. To upload the shapefile folder containing all the component parts, you'd have to use the 'folder' option.  The question then is, is there any way to know, from the event trigger perspective, that the operation was a folder upload, not just a file upload and to therefore wait until all the parts of the folder are uploaded OR if there is any event data in AWS that, when a FOLDER is uploaded it counts the underlying file parts (1 of 6, 2 of 6 etc) and could send an event after all the parts of the folder have been uploaded(?)

I also am aware of the 'multipart' upload which would, I think, do what I proposed in #3 above but that multipart 'tag' is only if you upload via sdk or cli. Unless the s3 console folder upload is underneath a multi-part upload?


问:
How to align two buttons in a stack panel without any spacing
I have been using UmaStackPanel to align two views in Xamarin iOS. Somehow, even when I don't specifically define the space, there's a huge gap between the two views. One on one corner and the other in the other corner. I have been trying to remove the gap between, and I have failed. How to go about this?

The first button looks like this:

```<code>UIButton test= new UIButton(UIButtonType.System)
{
    HorizontalAlignment = UIControlContentHorizontalAlignment.Left,
    TranslatesAutoresizingMaskIntoConstraints = false,
    TitleEdgeInsets = new UIEdgeInsets(0, 10, 0, 0),
    Font = UmaFont.GetDefaultAppFont(17f)
};
test.SetImage(IconUtils.arrow.ToUIImage(new CoreGraphics.CGSize(24, 24)), UIControlState.Normal);
test.SetTitle(My Test, UIControlState.Normal);
test.SetTitleColor(UIColor.Black, UIControlState.Normal);
test.TintColor = iconColor;

UIImageView testView = new UIImageView()
{
    ClipsToBounds = true,
    TranslatesAutoresizingMaskIntoConstraints = false,
};
testView.Layer.MasksToBounds = true;
testView.Layer.CornerRadius = 12;
testView.ContentMode = UIViewContentMode.ScaleAspectFit;
testView.Image = IconUtils.arrow.ToUIImage(new CoreGraphics.CGSize(24, 24));
testView.Layer.BorderWidth = 2;
</code>```

And I created a horizontal UmaStackPanel and added the views.

Body:
I have been using UmaStackPanel to align two views in Xamarin iOS. Somehow, even when I don't specifically define the space, there's a huge gap between the two views. One on one corner and the other in the other corner. I have been trying to remove the gap between, and I have failed. How to go about this?

The first button looks like this:

UIButton test= new UIButton(UIButtonType.System)
{
    HorizontalAlignment = UIControlContentHorizontalAlignment.Left,
    TranslatesAutoresizingMaskIntoConstraints = false,
    TitleEdgeInsets = new UIEdgeInsets(0, 10, 0, 0),
    Font = UmaFont.GetDefaultAppFont(17f)
};
test.SetImage(IconUtils.arrow.ToUIImage(new CoreGraphics.CGSize(24, 24)), UIControlState.Normal);
test.SetTitle(My Test, UIControlState.Normal);
test.SetTitleColor(UIColor.Black, UIControlState.Normal);
test.TintColor = iconColor;

UIImageView testView = new UIImageView()
{
    ClipsToBounds = true,
    TranslatesAutoresizingMaskIntoConstraints = false,
};
testView.Layer.MasksToBounds = true;
testView.Layer.CornerRadius = 12;
testView.ContentMode = UIViewContentMode.ScaleAspectFit;
testView.Image = IconUtils.arrow.ToUIImage(new CoreGraphics.CGSize(24, 24));
testView.Layer.BorderWidth = 2;

And I created a horizontal UmaStackPanel and added the views.


问:
How to catch "Failed to load module script"
I've got a Vue3 Frontend build with Vite and hosted by Netlify. Now I have the following problem:

User opens the site

Developer pushes code and a new version is deployed

User tries to navigate to a new view that is dynamically imported and gets the following error:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

The error makes sense as the user has the old router destination files and they are gone because of the deployment. I would like to catch the error and just reload the page.

How can I catch the error?

I've tried (but nothing is logged):

```<code>window.addEventListener("error", (event: ErrorEvent) => {
  console.log(event);
});
</code>```

I've also tried on my router (but error is still logged to Sentry):

```<code>router.onError((error, to) => {
  if (error.message.includes("Failed to fetch dynamically imported module")) {
    window.location.assign(to.fullPath);
  }
});
</code>```

EDIT: This question was marked to be the same question as this question: How to tell if a

Body:
I've got a Vue3 Frontend build with Vite and hosted by Netlify. Now I have the following problem:

User opens the site

Developer pushes code and a new version is deployed

User tries to navigate to a new view that is dynamically imported and gets the following error:

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

The error makes sense as the user has the old router destination files and they are gone because of the deployment. I would like to catch the error and just reload the page.

How can I catch the error?

I've tried (but nothing is logged):

window.addEventListener("error", (event: ErrorEvent) => {
  console.log(event);
});

I've also tried on my router (but error is still logged to Sentry):

router.onError((error, to) => {
  if (error.message.includes("Failed to fetch dynamically imported module")) {
    window.location.assign(to.fullPath);
  }
});

EDIT: This question was marked to be the same question as this question: How to tell if a


问:
pass a socket to a child component and register an event inside it
I want to pass a socket object to a child component and register an event inside it, here's a snipest of my code:

```<code>
let socket = useRef(0)
  useEffect(() => {
    socket.current = io(`${process.env.NEXT_PUBLIC_SOCKET_URL}/chat`, {
      auth: {
        token: getToken(),
      },
    });

    return () => {
      socket.current.close();
    };
  });

return <Child socket={socket} />
</code>```

inside the child:

```<code>useEffect(() => {
socket.current.on("createMessage", (msg) => {
      console.log(msg);
    });
})
</code>```

and if I did put the same code of the child inside the parent it's working as expected but I want it to work inside the child component

I tried to use a state instead but it's causing an infinit rendering so I decided to use a ref for now

Body:
I want to pass a socket object to a child component and register an event inside it, here's a snipest of my code:

let socket = useRef(0)
  useEffect(() => {
    socket.current = io(`${process.env.NEXT_PUBLIC_SOCKET_URL}/chat`, {
      auth: {
        token: getToken(),
      },
    });

    return () => {
      socket.current.close();
    };
  });

return <Child socket={socket} />

inside the child:

useEffect(() => {
socket.current.on("createMessage", (msg) => {
      console.log(msg);
    });
})

and if I did put the same code of the child inside the parent it's working as expected but I want it to work inside the child component

I tried to use a state instead but it's causing an infinit rendering so I decided to use a ref for now


问:
How does a "Proxy" work in DBus Bluez API?
I'm confused on how a proxy works in BlueZ DBus API. Currently, I'm writing a function that should read the characteristic value of a specific service.

In these function:

```<code>static void print_string(const char *str, void *user_data)
{
    printf("%s\n", str);
}

void bt_shell_hexdump(const unsigned char *buf, size_t len)
{
    util_hexdump(' ', buf, len, print_string, NULL);
}

static void read_reply(DBusMessage *message, void *user_data)
{
    DBusError error;
    DBusMessageIter iter, array;
    uint8_t *value;
    int len;

    dbus_error_init(&error);

    if (dbus_set_error_from_message(&error, message) == TRUE)
    {
        printf("Failed to read: %s\n", error.name);
        dbus_error_free(&error);
        return;
    }

    dbus_message_iter_init(message, &iter);

    if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
    {
        printf("Invalid response to read\n");
        return;
    }

    dbus_message_iter_recurse(&iter, &array);
    dbus_message_iter_get_fixed_array(&array, &value, &len);

    if (len < 0)
    {
        printf("Unable to parse value\n");
        return;
    }

    bt_shell_hexdump(value, len);
    return;
}

static void read_setup(DBusMessageIter *iter, void *user_data)
{
    DBusMessageIter dict;
    uint16_t *offset = user_data;

    dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
                    DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
                    DBUS_TYPE_STRING_AS_STRING
                    DBUS_TYPE_VARIANT_AS_STRING
                    DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
                    &dict);

    g_dbus_dict_append_entry(&dict, "offset", DBUS_TYPE_UINT16, offset);

    dbus_message_iter_close_container(iter, &dict);
}

static void read_attribute(GDBusProxy *proxy, uint16_t offset)
{
    if (g_dbus_proxy_method_call(proxy, "ReadValue", read_setup, read_reply, &offset, NULL) == FALSE)
    {
        printf("Failed to read\n");
        return;
    }

    printf("Attempting to read %s\n", g_dbus_proxy_get_path(proxy));
}

void gatt_read_attribute(void)
{
    GDBusProxy *proxy;

    const char *iface;
    int offset = 0;

    iface = g_dbus_proxy_get_interface(proxy);
    printf("Iface: %s\n", iface);
    if (!strcmp(iface, "org.bluez.GattCharacteristic1") || !strcmp(iface, "org.bluez.GattDescriptor1"))
    {
        read_attribute(proxy, offset);
        return;
    }
    return;
}
</code>```

I setup the proxy but reading the "iface" value returns NULL. Is there a way for me to set the specific interface I want the proxy for?

Can someone explain how these proxy's work?

I'm new to BlueZ DBus API. The code snippet is from BlueZ client.

Thank you

Body:
I'm confused on how a proxy works in BlueZ DBus API. Currently, I'm writing a function that should read the characteristic value of a specific service.

In these function:

static void print_string(const char *str, void *user_data)
{
    printf("%s\n", str);
}

void bt_shell_hexdump(const unsigned char *buf, size_t len)
{
    util_hexdump(' ', buf, len, print_string, NULL);
}

static void read_reply(DBusMessage *message, void *user_data)
{
    DBusError error;
    DBusMessageIter iter, array;
    uint8_t *value;
    int len;

    dbus_error_init(&error);

    if (dbus_set_error_from_message(&error, message) == TRUE)
    {
        printf("Failed to read: %s\n", error.name);
        dbus_error_free(&error);
        return;
    }

    dbus_message_iter_init(message, &iter);

    if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
    {
        printf("Invalid response to read\n");
        return;
    }

    dbus_message_iter_recurse(&iter, &array);
    dbus_message_iter_get_fixed_array(&array, &value, &len);

    if (len < 0)
    {
        printf("Unable to parse value\n");
        return;
    }

    bt_shell_hexdump(value, len);
    return;
}

static void read_setup(DBusMessageIter *iter, void *user_data)
{
    DBusMessageIter dict;
    uint16_t *offset = user_data;

    dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
                    DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
                    DBUS_TYPE_STRING_AS_STRING
                    DBUS_TYPE_VARIANT_AS_STRING
                    DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
                    &dict);

    g_dbus_dict_append_entry(&dict, "offset", DBUS_TYPE_UINT16, offset);

    dbus_message_iter_close_container(iter, &dict);
}

static void read_attribute(GDBusProxy *proxy, uint16_t offset)
{
    if (g_dbus_proxy_method_call(proxy, "ReadValue", read_setup, read_reply, &offset, NULL) == FALSE)
    {
        printf("Failed to read\n");
        return;
    }

    printf("Attempting to read %s\n", g_dbus_proxy_get_path(proxy));
}

void gatt_read_attribute(void)
{
    GDBusProxy *proxy;

    const char *iface;
    int offset = 0;

    iface = g_dbus_proxy_get_interface(proxy);
    printf("Iface: %s\n", iface);
    if (!strcmp(iface, "org.bluez.GattCharacteristic1") || !strcmp(iface, "org.bluez.GattDescriptor1"))
    {
        read_attribute(proxy, offset);
        return;
    }
    return;
}

I setup the proxy but reading the "iface" value returns NULL. Is there a way for me to set the specific interface I want the proxy for?

Can someone explain how these proxy's work?

I'm new to BlueZ DBus API. The code snippet is from BlueZ client.

Thank you


问:
Source Urls having '#' in them (anchor links) are not redirecting
I currently have a redirect filter working on an old site with 100+ html pages (static site). However, the remaining API docs (200+ pages) which all have a "#" in them are not redirecting. The original site was implemented as an SPA and hence had anchor links for all API docs; the target site have clean urls.

Snippet of UrlRedirectFilter

```<code><rule>
<name>Delete Transactions</name>
<from>^/api/#create-transaction-deletion$</from>
<to last="true" type="redirect">https://baseurl/apis/Transaction/deleteTransactions</to>
</code>```

```<code><rule>
<name>Payment Charge</name>
<from>^/api/#paymentcharge$</from>
<to last="true" type="redirect">https://baseurl/apis/Payment%20Method/PaymentMethodCharge/</to>
</code>```

Is there a hidden rule in url tuckey filter that discards anchor links? Is there a regex I need to be aware of? If none of the regex patterns work on the filter, what's the best way to move forward by extending urlrewriteFilter? Thanks!

Body:
I currently have a redirect filter working on an old site with 100+ html pages (static site). However, the remaining API docs (200+ pages) which all have a "#" in them are not redirecting. The original site was implemented as an SPA and hence had anchor links for all API docs; the target site have clean urls.

Snippet of UrlRedirectFilter

<rule>
<name>Delete Transactions</name>
<from>^/api/#create-transaction-deletion$</from>
<to last="true" type="redirect">https://baseurl/apis/Transaction/deleteTransactions</to>

<rule>
<name>Payment Charge</name>
<from>^/api/#paymentcharge$</from>
<to last="true" type="redirect">https://baseurl/apis/Payment%20Method/PaymentMethodCharge/</to>

Is there a hidden rule in url tuckey filter that discards anchor links? Is there a regex I need to be aware of? If none of the regex patterns work on the filter, what's the best way to move forward by extending urlrewriteFilter? Thanks!


问:
How do I change the shape of the background or make it transparent on popup.html for Chrome Extensions?
I making a Chrome Extension. How do you make the background transparent or just change the shape of it.

popup.html:

```<code><!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>Ellipses</title>
    <link rel="stylesheet" href="styles.css">
</head>
<body background="none">
    <div class="outside-frame">
        <dir class="inside-frame">
            <h1>hello</h1>
        </dir>
    </div>
</body>
</html>
</code>```

styles.css:

```<code>.outside-frame{
    background-color: rgb(32, 32, 32);
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
}
</code>```

manifest.json:

```<code>{
    "manifest_version": 3,
    "name":"Test Extension",
    "version": "1.0.0",
    "description": "pass",
    "content_scripts": [
        {
            "matches": ["<all_urls>"],
            "js": ["Content.js"]
        }
    ],
    "action": {
        "default_popup": "popup.html"
    }
}
</code>```

I tried to do this in the styles.css file:

```<code>body{
    background: none;
}
</code>```

Body:
I making a Chrome Extension. How do you make the background transparent or just change the shape of it.

popup.html:

<!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>Ellipses</title>
    <link rel="stylesheet" href="styles.css">

        <dir class="inside-frame">

hello

        </dir>

styles.css:

.outside-frame{
    background-color: rgb(32, 32, 32);
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
}

manifest.json:

{
    "manifest_version": 3,
    "name":"Test Extension",
    "version": "1.0.0",
    "description": "pass",
    "content_scripts": [
        {
            "matches": ["<all_urls>"],
            "js": ["Content.js"]
        }
    ],
    "action": {
        "default_popup": "popup.html"
    }
}

I tried to do this in the styles.css file:

body{
    background: none;
}


问:
Equivalent of wavefront align in Prometheus
I am new to Prometheus and trying to move existing dashboards from Wavefront to Prometheus.

The metric being used here is counter and it reset every 1 min by the library that pushes the metrics to wavefront.

Wavefront query:

```<code>align(${ds_unit}, sum, sum(ts(metricName_counter, cluster="${cluster_name}" and customer="${customer_name}"), customer))
</code>```

ds_unit here = 1 min

Prometheus query:
To replicate the reset after every min in wavefront, I am using increase function.

```<code>sum by (customer) (increase(metricName_counter [1m]))
</code>```

However, the issue is that wavefront sums it up by customer and then buckets it using align and sums it again whatever value falls in the bucket. I am not sure if we have something similar in Prometheus.

Body:
I am new to Prometheus and trying to move existing dashboards from Wavefront to Prometheus.

The metric being used here is counter and it reset every 1 min by the library that pushes the metrics to wavefront.

Wavefront query:

align(${ds_unit}, sum, sum(ts(metricName_counter, cluster="${cluster_name}" and customer="${customer_name}"), customer))

ds_unit here = 1 min

Prometheus query:
To replicate the reset after every min in wavefront, I am using increase function.

sum by (customer) (increase(metricName_counter [1m]))

However, the issue is that wavefront sums it up by customer and then buckets it using align and sums it again whatever value falls in the bucket. I am not sure if we have something similar in Prometheus.


问:
How to apply css rules to a link which is inside multiple divs?
In my html code I want to create a link to a Ratings page :

Ratings

```
<p>Css code :</p>
<pre class="lang-css prettyprint-override"><code>.product{
    margin: 2rem;
    position: relative;
}

.container{
    width: 88vw;
    margin: 0 auto;
}

.product-info{
    background: rgb(63, 34, 34);
    padding: 2rem;
}

.product-info-top{
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sm-title{
    font-weight: 300;
    font-size: 1rem;
    text-transform: uppercase;
}
</code>```

But when i tried changing the link appearance, as well as change its color when visited etc, it didnt affect the link :

a{
   text-decoration: none;
}
a:visited{
   color: #somehexvalue;
}
```

I also tried applying a class to this link tag but again did not work.

Body:
In my html code I want to create a link to a Ratings page :

Ratings

Css code :

.product{
    margin: 2rem;
    position: relative;
}

.container{
    width: 88vw;
    margin: 0 auto;
}

.product-info{
    background: rgb(63, 34, 34);
    padding: 2rem;
}

.product-info-top{
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sm-title{
    font-weight: 300;
    font-size: 1rem;
    text-transform: uppercase;
}

But when i tried changing the link appearance, as well as change its color when visited etc, it didnt affect the link :

a{
   text-decoration: none;
}
a:visited{
   color: #somehexvalue;
}

I also tried applying a class to this link tag but again did not work.


问:
Bug 'Plugin with id 'com.android.library' not found.' when include java module in flutter project
I'm creating a Flutter Project and I need import a Java module to use the Samsung IAP, but, when I insert the module, I get this problem: Plugin with id 'com.android.library' not found.

This is the build.gradle of the Samsung IAP Helper (IAP6Helper):

```<code>apply plugin: 'com.android.library'
android {
    compileSdkVersion 26
    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 26
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
}
</code>```

This is the build.gradle of the Samsung IAP Sample (IAP6Sample):

```<code>apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId 'com.samsung.android.sdk.iap.v6.sample1'
        minSdkVersion 18
        targetSdkVersion 26
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    productFlavors {
    }
}

dependencies {
    implementation project(':IAP6Helper')
}
</code>```

I see in some

```<code>dependencies {
    classpath 'com.android.tools.build:gradle:7.1.3'
}
</code>```

I already saw in some answers here that I should add the code below in my code, but it always was and nothing solves it.

Sorry my bad English.

Body:
I'm creating a Flutter Project and I need import a Java module to use the Samsung IAP, but, when I insert the module, I get this problem: Plugin with id 'com.android.library' not found.

This is the build.gradle of the Samsung IAP Helper (IAP6Helper):

apply plugin: 'com.android.library'
android {
    compileSdkVersion 26
    buildToolsVersion '28.0.3'

    defaultConfig {
        minSdkVersion 18
        targetSdkVersion 26
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
}

This is the build.gradle of the Samsung IAP Sample (IAP6Sample):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '28.0.3'

    defaultConfig {
        applicationId 'com.samsung.android.sdk.iap.v6.sample1'
        minSdkVersion 18
        targetSdkVersion 26
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }

    productFlavors {
    }
}

dependencies {
    implementation project(':IAP6Helper')
}

I see in some

dependencies {
    classpath 'com.android.tools.build:gradle:7.1.3'
}

I already saw in some answers here that I should add the code below in my code, but it always was and nothing solves it.

Sorry my bad English.


问:
Entering a four digit number using buttons in plotly dash
I want to enter values for a four digit number using a keypad input in Plotly Dash i.e. enter 2 and number displayed is 2, then enter 3 and number displayed is 23.

The below technically should achieve this:

```<code>import dash
import dash_daq as daq
import dash_html_components as html
from dash.dependencies import Input, Output

app = dash.Dash()

app.layout = html.Div([
    html.Div([
        html.Button(id='button-7', value='7', children='7', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button(id='button-8', value='8', children='8', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button(id='button-9', value='9', children='9', style={'fontSize':24, 'width': '33%', 'height': '60px'})
    ], style={'display': 'flex'}),
    html.Div([
        html.Button(id='button-4', value='4', children='4', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button(id='button-5', value='5', children='5', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button(id='button-6', value='6', children='6', style={'fontSize':24, 'width': '33%', 'height': '60px'})
    ], style={'display': 'flex'}),
    html.Div([
        html.Button(id='button-1', value='1', children='1', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button(id='button-2', value='2', children='2', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button(id='button-3', value='3', children='3', style={'fontSize':24, 'width': '33%', 'height': '60px'})
    ], style={'display': 'flex'}),
    html.Div([
        html.Button(id='button-0', value='0', children='0', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button('Reset', id='button-reset', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
    ], style={'display': 'flex'}),
    html.Div([
        html.Output(id='output', children='', style={'fontSize':48, 'width': '100%', 'height': '60px'})
    ], style={'display': 'flex'})
])

@app.callback(
    Output('output', 'children'),
    [Input('button-1', 'n_clicks'),
     Input('button-2', 'n_clicks'),
     Input('button-3', 'n_clicks'),
     Input('button-4', 'n_clicks'),
     Input('button-5', 'n_clicks'),
     Input('button-6', 'n_clicks'),
     Input('button-7', 'n_clicks'),
     Input('button-8', 'n_clicks'),
     Input('button-9', 'n_clicks'),
     Input('button-0', 'n_clicks'),
     State('output', 'children')])
def display_output(*n_clicks):
    ctx = dash.callback_context
    if not ctx.triggered:
        return ''
    else:
        button_id = ctx.triggered[0]['prop_id'].split('.')[0]
        button_value = button_id.split('-')[-1]
        output_value = ctx.inputs['output.children'] + button_value if len(ctx.inputs['output.children']) < 4 else ctx.inputs['output.children']
        return output_value

if __name__ == '__main__':
    app.run_server()
</code>```

But it is throwing an error:

output_value = ctx.inputs['output.children'] + button_value if
len(ctx.inputs['output.children']) < 4 else
ctx.inputs['output.children'] KeyError: 'output.children'

Essentially I want 'output.children' to be the previous state pre button press, but I can't work out how to save that and use it within the output_value statement in the function. Any ideas?

Body:
I want to enter values for a four digit number using a keypad input in Plotly Dash i.e. enter 2 and number displayed is 2, then enter 3 and number displayed is 23.

The below technically should achieve this:

import dash
import dash_daq as daq
import dash_html_components as html
from dash.dependencies import Input, Output

app = dash.Dash()

app.layout = html.Div([
    html.Div([
        html.Button(id='button-7', value='7', children='7', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button(id='button-8', value='8', children='8', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button(id='button-9', value='9', children='9', style={'fontSize':24, 'width': '33%', 'height': '60px'})
    ], style={'display': 'flex'}),
    html.Div([
        html.Button(id='button-4', value='4', children='4', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button(id='button-5', value='5', children='5', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button(id='button-6', value='6', children='6', style={'fontSize':24, 'width': '33%', 'height': '60px'})
    ], style={'display': 'flex'}),
    html.Div([
        html.Button(id='button-1', value='1', children='1', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button(id='button-2', value='2', children='2', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button(id='button-3', value='3', children='3', style={'fontSize':24, 'width': '33%', 'height': '60px'})
    ], style={'display': 'flex'}),
    html.Div([
        html.Button(id='button-0', value='0', children='0', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
        html.Button('Reset', id='button-reset', style={'fontSize':24, 'width': '33%', 'height': '60px'}),
    ], style={'display': 'flex'}),
    html.Div([
        html.Output(id='output', children='', style={'fontSize':48, 'width': '100%', 'height': '60px'})
    ], style={'display': 'flex'})
])

@app.callback(
    Output('output', 'children'),
    [Input('button-1', 'n_clicks'),
     Input('button-2', 'n_clicks'),
     Input('button-3', 'n_clicks'),
     Input('button-4', 'n_clicks'),
     Input('button-5', 'n_clicks'),
     Input('button-6', 'n_clicks'),
     Input('button-7', 'n_clicks'),
     Input('button-8', 'n_clicks'),
     Input('button-9', 'n_clicks'),
     Input('button-0', 'n_clicks'),
     State('output', 'children')])
def display_output(*n_clicks):
    ctx = dash.callback_context
    if not ctx.triggered:
        return ''
    else:
        button_id = ctx.triggered[0]['prop_id'].split('.')[0]
        button_value = button_id.split('-')[-1]
        output_value = ctx.inputs['output.children'] + button_value if len(ctx.inputs['output.children']) < 4 else ctx.inputs['output.children']
        return output_value

if __name__ == '__main__':
    app.run_server()

But it is throwing an error:

output_value = ctx.inputs['output.children'] + button_value if
len(ctx.inputs['output.children']) < 4 else
ctx.inputs['output.children'] KeyError: 'output.children'

Essentially I want 'output.children' to be the previous state pre button press, but I can't work out how to save that and use it within the output_value statement in the function. Any ideas?


问:
How to add SSL (HTTPS) in my NodeJS server
I Have code like this.

```<code>const pino = require('pino')
const { Boom } = require('@hapi/boom')
const fs = require('fs')
const chalk = require('chalk')
require('dotenv/config')
const express = require('express')
const socket = require("socket.io");
const { toDataURL } = require('qrcode')
const mysql = require('mysql');
require('dotenv').config();
const request = require('request');
const { smsg } = require('./app_node/lib/myf')

const app = express()
const host = process.env.HOST
const port = parseInt(process.env.PORT)
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
const ser = app.listen(port, host, () => {
    console.log(`Server is listening on http://${host}:${port}`)
})
const io = socket(ser);
</code>```

how do i get my code to run on the https server

i want to run my server in https in nodejs

Body:
I Have code like this.

const pino = require('pino')
const { Boom } = require('@hapi/boom')
const fs = require('fs')
const chalk = require('chalk')
require('dotenv/config')
const express = require('express')
const socket = require("socket.io");
const { toDataURL } = require('qrcode')
const mysql = require('mysql');
require('dotenv').config();
const request = require('request');
const { smsg } = require('./app_node/lib/myf')

const app = express()
const host = process.env.HOST
const port = parseInt(process.env.PORT)
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
const ser = app.listen(port, host, () => {
    console.log(`Server is listening on http://${host}:${port}`)
})
const io = socket(ser);

how do i get my code to run on the https server

i want to run my server in https in nodejs


问:
Shows wrong answer but i get correct answer when i run it in pycharm (codechef parctice problem- Bomb the base)
Here is the link to the probem : LINK

input :

```<code>2
8 6
4 1 6 1 6 5 6 8
2 1
3 5
</code>```

Outtput :

```<code>6
0
</code>```

Here's the code i wrote :

cook your dish here

```<code>test_case = int(input('T:'))
for i in range(test_case) :
    list1=[]
    list2=[]
    input_1=input("input 1:")
    list1=input_1.split(" ")
    list1=list(map(int,list1))
    input2= input("input 2:")
    list2=input2.split(" ")
    list2= list(map(int,lis`your text`t2))
    list2.reverse()
    c=0
    for i in  list2:
        c+=1
        if i<list1[1] :
            print(list1[0]-c+1)
            break
        elif c==list1[0]:
            print("0")

</code>```

Body:
Here is the link to the probem : LINK

input :

2
8 6
4 1 6 1 6 5 6 8
2 1
3 5

Outtput :

6
0

Here's the code i wrote :

cook your dish here

test_case = int(input('T:'))
for i in range(test_case) :
    list1=[]
    list2=[]
    input_1=input("input 1:")
    list1=input_1.split(" ")
    list1=list(map(int,list1))
    input2= input("input 2:")
    list2=input2.split(" ")
    list2= list(map(int,lis`your text`t2))
    list2.reverse()
    c=0
    for i in  list2:
        c+=1
        if i<list1[1] :
            print(list1[0]-c+1)
            break
        elif c==list1[0]:
            print("0")


问:
Modify Tkinter Label from another class in an other file
In main.py there is class MainFrame which display Player._money
In lands.py there is class Lands which allows the player to buy more lands.
Inside class Lands, there is a function called def buy_lands(self) that respond to a button.

here's my problem:
When buy_lands(self) is clicked, i've managed to update the label that shows the Player._lands as it's in the same class, same frame. However, the label that display the money is in a different frame, different class and a different file as it's in main.py class MainFrame.

How can i update Player._money in MainFrame from buy_lands(self) in class Lands without having a circular import error?

Here's the code if that's help:

main.py

```<code>import tkinter as tk
from tkinter import ttk
from lands import Lands
from player import Player

class MainFrame(ttk.Frame):
    def __init__(self, container):
        super().__init__(container)

        options = {'padx': 5, 'pady': 5}

        self.player = Player._name

        self.__create_widgets()

        # show the frame on the container
        self.pack(**options)

    def __create_widgets(self):
        # Initialize style
        s = ttk.Style()

        # Frame Top Menu
        s.configure('Menu.TFrame', background='blue') # define the style
        self.menu = ttk.Frame(self, height=100, width=450, style='Menu.TFrame') # create the frame
        self.menu.pack() # place the frame

        # Main Frame
        s.configure('Main.TFrame', background='red')
        self.main = ttk.Frame(self, height=300, width=300, style='Main.TFrame')
        self.main.pack()

        # Create Widgets
        self.name_label = ttk.Label(self.menu, text=f'Welcome {Player._name}')
        self.money_label =  ttk.Label(self.menu, text=f'money: {Player._money} £')
        self.button_1 = ttk.Button(self.menu, text="Button 1")
        self.lands_button = ttk.Button(self.menu, text="Lands", command=self.show_lands)
        self.button_3 = ttk.Button(self.menu, text="Button 3")
        self.button_4 = ttk.Button(self.menu, text="Button 4")

        # Display Widgets
        self.name_label.grid(column=0, columnspan=1, row=0, sticky='w')
        self.money_label.grid(column=2, row=0, columnspan=3, sticky='e')
        self.button_1.grid(column=0, row=1)
        self.lands_button.grid(column=1, row=1)
        self.button_3.grid(column=2, row=1)
        self.button_4.grid(column=3, row=1)

    def show_lands(self):
        for widget in self.main.winfo_children():
            widget.destroy()
        Lands(self.main)

</code>```

lands.py

```<code>import tkinter as tk
from tkinter import ttk
from player import Player

class Lands(ttk.Frame):
    def __init__(self, container):
      super().__init__(container)
      self.lands = Player._lands
      options = {'padx': 5, 'pady': 5}

    # show the frame on the container
      self.pack(**options)

      self.__create_widgets()

    def __create_widgets(self):
      self.lands_label = ttk.Label(self, text=f'You have {Player._lands} acres of lands')
      self.buy_lands_button = ttk.Button(self, text="Buy Lands", command=self.buy_lands)
      self.lands_label.pack()
      self.buy_lands_button.pack()

    def buy_lands(self):
        Player._money -= 5000
        Player._lands += 10
        self.lands_label.config(text=f'You have {Player._lands} acres of lands')

        self.lands_label.pack()
        print(Player._money)
        print(Player._lands)

</code>```

i've tryed lambda methods but as i'm still learning i'm not too sure how to use it. I've tried global method but again because it's not in the same file, it doesn't work. And i tried to import MainFrame which shows a circular import error.

Body:
In main.py there is class MainFrame which display Player._money
In lands.py there is class Lands which allows the player to buy more lands.
Inside class Lands, there is a function called def buy_lands(self) that respond to a button.

here's my problem:
When buy_lands(self) is clicked, i've managed to update the label that shows the Player._lands as it's in the same class, same frame. However, the label that display the money is in a different frame, different class and a different file as it's in main.py class MainFrame.

How can i update Player._money in MainFrame from buy_lands(self) in class Lands without having a circular import error?

Here's the code if that's help:

main.py

import tkinter as tk
from tkinter import ttk
from lands import Lands
from player import Player

class MainFrame(ttk.Frame):
    def __init__(self, container):
        super().__init__(container)

        options = {'padx': 5, 'pady': 5}

        self.player = Player._name

        self.__create_widgets()

        # show the frame on the container
        self.pack(**options)

    def __create_widgets(self):
        # Initialize style
        s = ttk.Style()

        # Frame Top Menu
        s.configure('Menu.TFrame', background='blue') # define the style
        self.menu = ttk.Frame(self, height=100, width=450, style='Menu.TFrame') # create the frame
        self.menu.pack() # place the frame

        # Main Frame
        s.configure('Main.TFrame', background='red')
        self.main = ttk.Frame(self, height=300, width=300, style='Main.TFrame')
        self.main.pack()

        # Create Widgets
        self.name_label = ttk.Label(self.menu, text=f'Welcome {Player._name}')
        self.money_label =  ttk.Label(self.menu, text=f'money: {Player._money} £')
        self.button_1 = ttk.Button(self.menu, text="Button 1")
        self.lands_button = ttk.Button(self.menu, text="Lands", command=self.show_lands)
        self.button_3 = ttk.Button(self.menu, text="Button 3")
        self.button_4 = ttk.Button(self.menu, text="Button 4")

        # Display Widgets
        self.name_label.grid(column=0, columnspan=1, row=0, sticky='w')
        self.money_label.grid(column=2, row=0, columnspan=3, sticky='e')
        self.button_1.grid(column=0, row=1)
        self.lands_button.grid(column=1, row=1)
        self.button_3.grid(column=2, row=1)
        self.button_4.grid(column=3, row=1)

    def show_lands(self):
        for widget in self.main.winfo_children():
            widget.destroy()
        Lands(self.main)

lands.py

import tkinter as tk
from tkinter import ttk
from player import Player

class Lands(ttk.Frame):
    def __init__(self, container):
      super().__init__(container)
      self.lands = Player._lands
      options = {'padx': 5, 'pady': 5}

    # show the frame on the container
      self.pack(**options)

      self.__create_widgets()

    def __create_widgets(self):
      self.lands_label = ttk.Label(self, text=f'You have {Player._lands} acres of lands')
      self.buy_lands_button = ttk.Button(self, text="Buy Lands", command=self.buy_lands)
      self.lands_label.pack()
      self.buy_lands_button.pack()

    def buy_lands(self):
        Player._money -= 5000
        Player._lands += 10
        self.lands_label.config(text=f'You have {Player._lands} acres of lands')

        self.lands_label.pack()
        print(Player._money)
        print(Player._lands)

i've tryed lambda methods but as i'm still learning i'm not too sure how to use it. I've tried global method but again because it's not in the same file, it doesn't work. And i tried to import MainFrame which shows a circular import error.


问:
Prefilled a form and get URL
I am trying to prefill a website form and get the URL. I was able to find the varaible name using Chrome developer tool. For example, the one in the image is "app_email". However, when I change the URL accoridng to the instructions and reopen with the new URL, the form is not prefilled. Is there any suggestions? Thanks

I tried to edit the URL as stated above

Title: Prefilled a form and get URL


问:
Is it possible to tell the compiler that an object reachable through a pointer has changed?
Is there a way to tell the C++ compiler that an object that's reachable through a pointer has changed, even if it has every reason to believe it hasn't?

My use-case is something like this:

```<code>// Three argument system call.
inline unsigned long do_syscall(unsigned short callnum,
                                unsigned long p1,
                                unsigned long p2,
                                unsigned long p3) noexcept
{
   val_t retval;
   asm volatile (
      "syscall\n\t"
       :"=a"(retval)
       :"a"(static_cast<::std::uint64_t>(callnum)), "D"(p1), "S"(p2), "d"(p3)
       :"%rcx", "%r11"
      );
   return retval;
}

inline void read(int fd, char *buf, int size) noexcept {
   do_syscall(0, fd, reinterpret_cast<unsigned long>(buf), size);
}

char buf[1024] = {'\0'};
read(0, buf, 1024);
// Here, the compiler needs to believe it knows nothing about what's in buf.
</code>```

The compiler has full access to the code for read, and it has every reason to believe that read doesn't modify the contents of buf. Is there anything I can put in read that would doesn't result in any code by itself, but does tell the compiler it must read the contents of buf from memory again if it's accessed?

An answer specific to gcc and/or clang would be acceptable, but I would prefer a method that was standard C++.

Body:
Is there a way to tell the C++ compiler that an object that's reachable through a pointer has changed, even if it has every reason to believe it hasn't?

My use-case is something like this:

// Three argument system call.
inline unsigned long do_syscall(unsigned short callnum,
                                unsigned long p1,
                                unsigned long p2,
                                unsigned long p3) noexcept
{
   val_t retval;
   asm volatile (
      "syscall\n\t"
       :"=a"(retval)
       :"a"(static_cast<::std::uint64_t>(callnum)), "D"(p1), "S"(p2), "d"(p3)
       :"%rcx", "%r11"
      );
   return retval;
}

inline void read(int fd, char *buf, int size) noexcept {
   do_syscall(0, fd, reinterpret_cast<unsigned long>(buf), size);
}

char buf[1024] = {'\0'};
read(0, buf, 1024);
// Here, the compiler needs to believe it knows nothing about what's in buf.

The compiler has full access to the code for read, and it has every reason to believe that read doesn't modify the contents of buf. Is there anything I can put in read that would doesn't result in any code by itself, but does tell the compiler it must read the contents of buf from memory again if it's accessed?

An answer specific to gcc and/or clang would be acceptable, but I would prefer a method that was standard C++.


问:
Array as query string
I've created a function that pushes objects into an array onclick. How do I use that array as a query string combined with other query string parameters?

```<code><input type="checkbox" onclick="querySearch('uno')" id="coverage1">
    <input type="checkbox" onclick="querySearch('dos')" id="coverage2">
    <input type="checkbox" onclick="querySearch('tres')" id="coverage3">
    <input type="checkbox" onclick="querySearch('quattro')" id="coverage4">
    <script>
        let searchCoverage = [];

        function querySearch(a) {
            if (searchCoverage.indexOf(a) > -1) {
                searchCoverage.splice(searchCoverage.indexOf(a), 1);
            }
            else {
            searchCoverage.push(a);
        }
            if (searchCoverage.length == 0) {
                console.log();
            }
            else {
                console.log(searchCoverage);
            }
        }
</code>```

This outputs an array in the console as long as there are objects in the array. I would like to add this array to a href but my problem is there are multiple query string parameters already in that href.

Thanks in advance.

Title: Array as query string

Body:
I've created a function that pushes objects into an array onclick. How do I use that array as a query string combined with other query string parameters?

<input type="checkbox" onclick="querySearch('uno')" id="coverage1">
    <input type="checkbox" onclick="querySearch('dos')" id="coverage2">
    <input type="checkbox" onclick="querySearch('tres')" id="coverage3">
    <input type="checkbox" onclick="querySearch('quattro')" id="coverage4">


问:
GA4 - Measurement Protocol Issue - gtag + client_id + session_id not merge on reports
We have migrated the UA to GA4. We use gtag.js for most of the events on the website and the Measurement Protocol for the purchase.

We noticed that the measurement protocol event has a problem with reporting at the sessions level on channels grouping because everything is classified as "not set", and we have a significant amount of purchases that are not linked to client_id. We are collecting a unique hit with the purchase (print screen attached).

We followed all the requirements on the documentation, and after discussions with other web analytics, it should be an issue with the Measurement Protocol.

We need your assistance to find a solution to this tracking problem.

```<code>url = "https://www.google-analytics.com//mp/collect?api_secret=API_Secrect&measurement_id=G-0000000000"
payload = {
  "client_id": "685297041.1666940000",
  "user_id": "#1234",
  "non_personalized_ads": 'false',
  "user_properties":{
    "cust_numb":{
      "value":"#1234"},
    "internal_user":{
      "value":"false"}},
  "events": [
    {
      "name": "purchase",
      "params": {
        "items": [
          {
            "price": 3.35,
            "quantity": 1,
            "item_id": "#1062",
            "item_name": "White Fine Filters",
            "affiliation": "client.com",
            "currency": "USD",
            "discount": 0.5,
            "item_variant": "NA",
            "item_category": "Filters",
            "item_brand": "Generic",
            "index": 0,
            "item_category2": "One_Time",
            "item_category3": "simple_product",
            "item_category4": "full_price",
            "item_category5": "in stock"
          },
          {
            "price": 15.95,
            "quantity": 1,
            "item_id": "#1068",
            "item_name": "Black Filters for PR",
            "affiliation": "client.com",
            "currency": "USD",
            "discount": 5.8,
            "item_variant": "NA",
            "item_category": "Supplies/Filters/Sale 2021",
            "item_brand": "Generic",
            "index": 1,
            "item_category2": "one_time",
            "item_category3": "simple_product",
            "item_category4": "Discounted",
            "item_category5": "in_stock"
          }],
        "affiliation": "",
        "coupon": "ALL10",
        "currency": "USD",
        "transaction_id": "#2_02022",
        "shipping": 5,
        "tax": 0.35,
        "value": 15,
        "session_id": "1666947000",
        "timestamp_micros": "1666948174531000",
        "engagement_time_msec": "1000"
       }
    }
  ]
}

requests.post(url,data=json.dumps(payload))
</code>```

enter image description here

I tested everything.

Could you let me know if you are facing the same issue?

I noticed this on the documentation, but it's not detailed what partial reporting is.

"Full Server-to-Server
While it is possible to send events to Google Analytics solely with measurement protocol, only partial reporting may be available. The purpose of the measurement protocol is to augment existing events collected via gtag, GTM, or Firebase. Some event and parameter names are reserved for use via automatic collection and cannot be sent through the measurement protocol."

Thank you,

Body:
We have migrated the UA to GA4. We use gtag.js for most of the events on the website and the Measurement Protocol for the purchase.

We noticed that the measurement protocol event has a problem with reporting at the sessions level on channels grouping because everything is classified as "not set", and we have a significant amount of purchases that are not linked to client_id. We are collecting a unique hit with the purchase (print screen attached).

We followed all the requirements on the documentation, and after discussions with other web analytics, it should be an issue with the Measurement Protocol.

We need your assistance to find a solution to this tracking problem.

url = "https://www.google-analytics.com//mp/collect?api_secret=API_Secrect&measurement_id=G-0000000000"
payload = {
  "client_id": "685297041.1666940000",
  "user_id": "#1234",
  "non_personalized_ads": 'false',
  "user_properties":{
    "cust_numb":{
      "value":"#1234"},
    "internal_user":{
      "value":"false"}},
  "events": [
    {
      "name": "purchase",
      "params": {
        "items": [
          {
            "price": 3.35,
            "quantity": 1,
            "item_id": "#1062",
            "item_name": "White Fine Filters",
            "affiliation": "client.com",
            "currency": "USD",
            "discount": 0.5,
            "item_variant": "NA",
            "item_category": "Filters",
            "item_brand": "Generic",
            "index": 0,
            "item_category2": "One_Time",
            "item_category3": "simple_product",
            "item_category4": "full_price",
            "item_category5": "in stock"
          },
          {
            "price": 15.95,
            "quantity": 1,
            "item_id": "#1068",
            "item_name": "Black Filters for PR",
            "affiliation": "client.com",
            "currency": "USD",
            "discount": 5.8,
            "item_variant": "NA",
            "item_category": "Supplies/Filters/Sale 2021",
            "item_brand": "Generic",
            "index": 1,
            "item_category2": "one_time",
            "item_category3": "simple_product",
            "item_category4": "Discounted",
            "item_category5": "in_stock"
          }],
        "affiliation": "",
        "coupon": "ALL10",
        "currency": "USD",
        "transaction_id": "#2_02022",
        "shipping": 5,
        "tax": 0.35,
        "value": 15,
        "session_id": "1666947000",
        "timestamp_micros": "1666948174531000",
        "engagement_time_msec": "1000"
       }
    }
  ]
}

requests.post(url,data=json.dumps(payload))

enter image description here

I tested everything.

Could you let me know if you are facing the same issue?

I noticed this on the documentation, but it's not detailed what partial reporting is.

"Full Server-to-Server
While it is possible to send events to Google Analytics solely with measurement protocol, only partial reporting may be available. The purpose of the measurement protocol is to augment existing events collected via gtag, GTM, or Firebase. Some event and parameter names are reserved for use via automatic collection and cannot be sent through the measurement protocol."

Thank you,


问:
Openliberty looking in wrong location for application dependencies
I have a multi-module java / maven application that I'd like to run on openliberty in dev mode (mvn liberty:dev). The application is structured as follows:

```<code>root
\ejb
\ear
</code>```

OpenLiberty is looking for dependencies in the \ejb\target\classes folder on application startup but not finding the dependencies because they are not there. However, they do exist in the \ear\target\classes folder.

I think liberty should be looking in \ear\target\classes for its dependencies. This is because the maven build compiles them into the ear, not the ejb jar.

I assume the correct fix for this is to tell liberty (somehow) where to find the application dependencies (that live in \ear\target\classes not \ejb\target\classes).

Does this sound like the correct fix and does anyone know how to tell liberty to look for the dependencies in the correct location?

As a side note, I am getting the message

```<code>[WARNING] CWWKM2179W: The application is not defined in the server configuration but the POM configuration indicates it should be installed in the apps folder. Application configuration is being added to the target server configuration dropins folder by the plug-in.
</code>```

On openliberty startup.

This is even though the absolute path to the ear file is specified in server.xml in the ear file like so:

```<code><enterpriseApplication id="my-app"
        type="ear" location="C:\Users\ absolute path to my app"
        name="my-app" contextRoot="/" />
</code>```

I am additionally wondering if this log warning might be related to the trouble I'm having.

Here is an example of the messages I am getting on startup:

```<code>[INFO] [WARNING ] SRVE9967W: The manifest class path myjar-SNAPSHOT.jar can not be found in jar file file:/c:/my-app/ejb/target/classes/ or its parent.
</code>```

If it looked in

```<code>file:/c:/my-app/ear/
</code>```

I think I'd be good.

Body:
I have a multi-module java / maven application that I'd like to run on openliberty in dev mode (mvn liberty:dev). The application is structured as follows:

root
\ejb
\ear

OpenLiberty is looking for dependencies in the \ejb\target\classes folder on application startup but not finding the dependencies because they are not there. However, they do exist in the \ear\target\classes folder.

I think liberty should be looking in \ear\target\classes for its dependencies. This is because the maven build compiles them into the ear, not the ejb jar.

I assume the correct fix for this is to tell liberty (somehow) where to find the application dependencies (that live in \ear\target\classes not \ejb\target\classes).

Does this sound like the correct fix and does anyone know how to tell liberty to look for the dependencies in the correct location?

As a side note, I am getting the message

[WARNING] CWWKM2179W: The application is not defined in the server configuration but the POM configuration indicates it should be installed in the apps folder. Application configuration is being added to the target server configuration dropins folder by the plug-in.

On openliberty startup.

This is even though the absolute path to the ear file is specified in server.xml in the ear file like so:

<enterpriseApplication id="my-app"
        type="ear" location="C:\Users\ absolute path to my app"
        name="my-app" contextRoot="/" />

I am additionally wondering if this log warning might be related to the trouble I'm having.

Here is an example of the messages I am getting on startup:

[INFO] [WARNING ] SRVE9967W: The manifest class path myjar-SNAPSHOT.jar can not be found in jar file file:/c:/my-app/ejb/target/classes/ or its parent.

If it looked in

file:/c:/my-app/ear/

I think I'd be good.


问:
adding weight edge to Network graph in Python
I have a large dataframe(df) with Weight ,Source Node, target columns.

SourceNode
target
Weight

176890
657826
201

136578
589231
300

143873
457139
50

134589
892147
550

198345
678931
350

112443
525188
600

336128
689313
1500

Source node and target column are object and weight is int data type.
I am trying to create a network graph which shows the connectivity from source node to target column (unidirect) and the edge need to reflect the weight value( like by stronger bigger connection).

This is the code I am using :

```<code>import networkx as nx

G= nx.from_pandas_edgelist(df_new, source = 'SourceNode', target='target' , edge_attr= 'Weight')

edges = G.edges.data()

pos = nx.kamada_kawai_layout(G)
edge_width = [e[2]['Weight'] for e in edges]
nx.draw(G, pos=pos, with_labels=True) # draw nodes (and edges!)
nx.draw_networkx_edges(G, pos=pos, width=edge_width)

</code>```

I getting odd graph that everything is black.
I am very new to visualization in pandas. I appreciate any help.

Body:
I have a large dataframe(df) with Weight ,Source Node, target columns.

SourceNode
target
Weight

176890
657826
201

136578
589231
300

143873
457139
50

134589
892147
550

198345
678931
350

112443
525188
600

336128
689313
1500

Source node and target column are object and weight is int data type.
I am trying to create a network graph which shows the connectivity from source node to target column (unidirect) and the edge need to reflect the weight value( like by stronger bigger connection).

This is the code I am using :

import networkx as nx

G= nx.from_pandas_edgelist(df_new, source = 'SourceNode', target='target' , edge_attr= 'Weight')

edges = G.edges.data()

pos = nx.kamada_kawai_layout(G)
edge_width = [e[2]['Weight'] for e in edges]
nx.draw(G, pos=pos, with_labels=True) # draw nodes (and edges!)
nx.draw_networkx_edges(G, pos=pos, width=edge_width)

I getting odd graph that everything is black.
I am very new to visualization in pandas. I appreciate any help.


问:
Yaml vscode plugin from red hat does not validate anything
I installed this in VSCode, created schema, reloaded and yes, I can see a line above my YAML files, telling me it sees and know the schema.

But... it does give me neither completion, nor error messages when I type things that do not exist in the schema.

Here is the shema.

It does not show me errors even on nonsense like this:

my.yaml:

```<code>wrong: value
another_wrong: value
  - hello
    lala
</code>```

What am I doing incorrectly? Thank you for help!

Body:
I installed this in VSCode, created schema, reloaded and yes, I can see a line above my YAML files, telling me it sees and know the schema.

But... it does give me neither completion, nor error messages when I type things that do not exist in the schema.

Here is the shema.

It does not show me errors even on nonsense like this:

my.yaml:

wrong: value
another_wrong: value
  - hello
    lala

What am I doing incorrectly? Thank you for help!


问:
Can QAbstractItemModel.beginInsertRows() be given an overestimate of the number of rows to be inserted?
I am using a custom QSqlTableModel class to edit an SQL table, which has certain constraints (e.g. a UNIQUE constraint). Because of these SQL constraints, at the time .insertRows() is called on a new batch of rows, it is not known which (or how many) of those rows will be successfully inserted. Therefore, when reimplementing the .insertRows() function, is it kosher to give .beginInsertRows() the upper limit of the number of rows which will be inserted, or will this cause problems down the line?

See https://doc.qt.io/qtforpython/PySide6/QtCore/QAbstractItemModel.html#PySide6.QtCore.PySide6.QtCore.QAbstractItemModel.beginInsertRows


问:
Tree view in VB.Net
Is there any way to find a node in treeview using xpath?
Also I wanted to expand only the selected path of the node in treeview when found.

Sample:

```
+ A
+ B
- C
  + C.1
  + C.2
  - C.3
    - C.3.1
  + C.4
+ D
+ E
```

Problem:

Find C.3.1 using "C/C.3/C.3.1"
and when found expand only C/C.3/C.3.1

ContentLicense: CC BY-SA 3.0

Title: Tree view in VB.Net

Body:
Is there any way to find a node in treeview using xpath?
Also I wanted to expand only the selected path of the node in treeview when found.

Sample:

+ A
+ B
- C
  + C.1
  + C.2
  - C.3
    - C.3.1
  + C.4
+ D
+ E

Problem:

Find C.3.1 using "C/C.3/C.3.1"
and when found expand only C/C.3/C.3.1


问:
React.JS build works in dev server but not in AWS Amplify when anything changes in package.json
I am a little bit perplexed here as I attempt to launch my first react project online.
I'm using AWS Amplify, I have connected my github repo, and have everything linked together, from VS Code I can push to my github, which then after a minute or so displays the changes inside of my AWS Amplify website, so I believe I have the vscode - GH - amplify pipeline operating properly...
I initialized a base react app, on the AWS site and it works as expected,
The dev server on localhost displays the same spinning logo and
Edit src/App.js and save to reload
I then added some extra random text as a test, within the app.js,
It added my hello world test text in the localhost. I push it to GH, it then appears exactly the same on my Amplify site as it does on dev server. the same react initial page but now both have the test text. I then delete all the components of the app.js
add a simple header nav bar, update package.json to include a couple dependencies (chakra-ui) and then the whole thing breaks.
I'm sorry if this is a dumb question but do I need to do anything outside of vs code, in order to have the package.json updates not ruin the compiling?

In VS Code i need to npm install packages do I need to do this somewhere inside AWS Amplify?

here is the json that works fine

```<code>{
  "name": "react-amplify-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
</code>```

I then try to add the JSON file from my full react project where i made a decently involved (for me anyway) website.
Here is the updated JSON that makes it not work anymore

```<code>{
  "homepage": "https://avarga1.github.io/My-Portfolio/",
  "name": "myreactportfolio11",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@chakra-ui/core": "^0.8.0",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "iframe-resizer": "^4.2.11",
    "react": "^18.2.0",
    "react-bootstrap": "^2.7.0",
    "react-dom": "^18.2.0",
    "react-s3": "^1.3.1",
    "react-scripts": "^5.0.1",
    "scripts": "^0.1.0",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "gh-pages": "^4.0.0"
  }
}

</code>```

What am I missing???
Thanks in advance.

Body:
I am a little bit perplexed here as I attempt to launch my first react project online.
I'm using AWS Amplify, I have connected my github repo, and have everything linked together, from VS Code I can push to my github, which then after a minute or so displays the changes inside of my AWS Amplify website, so I believe I have the vscode - GH - amplify pipeline operating properly...
I initialized a base react app, on the AWS site and it works as expected,
The dev server on localhost displays the same spinning logo and
Edit src/App.js and save to reload
I then added some extra random text as a test, within the app.js,
It added my hello world test text in the localhost. I push it to GH, it then appears exactly the same on my Amplify site as it does on dev server. the same react initial page but now both have the test text. I then delete all the components of the app.js
add a simple header nav bar, update package.json to include a couple dependencies (chakra-ui) and then the whole thing breaks.
I'm sorry if this is a dumb question but do I need to do anything outside of vs code, in order to have the package.json updates not ruin the compiling?

In VS Code i need to npm install packages do I need to do this somewhere inside AWS Amplify?

here is the json that works fine

{
  "name": "react-amplify-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

I then try to add the JSON file from my full react project where i made a decently involved (for me anyway) website.
Here is the updated JSON that makes it not work anymore

{
  "homepage": "https://avarga1.github.io/My-Portfolio/",
  "name": "myreactportfolio11",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@chakra-ui/core": "^0.8.0",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "iframe-resizer": "^4.2.11",
    "react": "^18.2.0",
    "react-bootstrap": "^2.7.0",
    "react-dom": "^18.2.0",
    "react-s3": "^1.3.1",
    "react-scripts": "^5.0.1",
    "scripts": "^0.1.0",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d build",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "gh-pages": "^4.0.0"
  }
}

What am I missing???
Thanks in advance.


问:
date not showing in mat field
I have a date for example "2005-12-24T00:00:00" - this is the way it come from the server,
using it this way show nothing to the user (after getting the data)

```<code><mat-form-field>
  <mat-label>example</mat-label>
  <input matInput  autocomplete="off"
         placeholder="00/00/0000" type="date"
         [formControlName]="'example'">
</mat-form-field>
</code>```

why?
what I missed?

Title: date not showing in mat field

Body:
I have a date for example "2005-12-24T00:00:00" - this is the way it come from the server,
using it this way show nothing to the user (after getting the data)

<mat-form-field>
  <mat-label>example</mat-label>
  <input matInput  autocomplete="off"
         placeholder="00/00/0000" type="date"
         [formControlName]="'example'">
</mat-form-field>

why?
what I missed?


问:
Parent.Grid + Child.Grid => Shared ColumnDefinitions
I want to share a parent column definition with a child grid.

I have a parent grid like:

```<code><Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto" />
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="Auto" />
  </Grid.ColumnDefinitions>
  <controls:GridEntry />
  <controls:GridEntry />
  <controls:GridEntry />
</Grid>
</code>```

and a child that is a UserControl (controls:GridEntry) with following content:

```<code><Grid>
  <Label x:Name="caption" />
  <TextBox x:Name="value" />
  <Button x:Name="button" />
</Grid>
</code>```

My current idea is to find the parent grid from the child and set the constraints (if possible as binding, otherwise copy. When copying I have to catch all resize operations manually).

Is there an easy way to transfer the ColumnDefinitions of the parent grid to the child grid (preferably via XAML)?

Body:
I want to share a parent column definition with a child grid.

I have a parent grid like:

<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto" />
    <ColumnDefinition Width="*" />
    <ColumnDefinition Width="Auto" />
  </Grid.ColumnDefinitions>
  <controls:GridEntry />
  <controls:GridEntry />
  <controls:GridEntry />
</Grid>

and a child that is a UserControl (controls:GridEntry) with following content:

<Grid>

  <TextBox x:Name="value" />
  <Button x:Name="button" />
</Grid>

My current idea is to find the parent grid from the child and set the constraints (if possible as binding, otherwise copy. When copying I have to catch all resize operations manually).

Is there an easy way to transfer the ColumnDefinitions of the parent grid to the child grid (preferably via XAML)?


问:
Code runs partially on double clicking .py file
First, I am still a noob so please bear with me.
I have written some code that helps automate links formation and gallery creation for a website.
It all seems to work just fine when I run it in VS code, but when I try to double click the thumb_maker.py file only the first "module" seems to be executed. When I double click it, a window opens and I get asked to input the URL which is what should happen, but then the window closes and nothing else happens. There should be 3 inputs in total: Enter Gallery URL:, Choose gallery FILE name, and Choose gallery name. The code is separated in 3 "modules" (files): jpg_lister.py, page_maker.py and thumb_maker.py

(Edit from 11.01.2023) I tried it again on a different PC and it all works just fine so I suspect it's a Python installation problem on the other PC. I recently installed Invoke AI (a web based GUI for stable diffusion) on the problematic PC and it also installed Python I think, so I think it kinda messed things up. Any ideas what I can do to fix it or check my hypothesis?

here is the code for all 3:

**Code for jpg_lister.py: **

```<code>import requests

url = input("Enter Gallery URL: ")
data = requests.get(url).json()

links = []
for m in data['media']:
    links.append(m['url'])

formated_links = []

for link in links:
    formated_links.append(f'<a href={link} data-rel="lightcase: gallery" title="Caption Text">\n\
                        <img src={link} alt="">\n\
                    </a>\n\
')
</code>```

**code for page_maker.py: **

```<code>from jpg_lister import formated_links

line_to_start = 91  # the line we want to start at
gallery_template = "gallery-justified-fullwidth-blanc.html"

with open(gallery_template, 'r', encoding='utf8') as file:
    lines = file.readlines()

lines[line_to_start:line_to_start] = formated_links

new_gallery = "gallery-justified-fullwidth-" + \
    input("Choose gallery FILE name: ") + ".html"
with open(new_gallery, 'w', encoding='utf8') as file:
    file.writelines(lines)

</code>```

**code for thumb_maker.py: **

```<code>from jpg_lister import links
from page_maker import new_gallery

def thumb_mkr():
    line_to_start = 89  # the line we want to start at
    gallery_inter = "gallery-albums-fullwidth-inter.html"

    gallery_name = input("Choose Gallery name: ")
    thumb_img = links[0]

    with open(gallery_inter, 'r', encoding='utf8') as file:
        lines = file.readlines()
    # now we have an array of lines. If we want to edit the line 89...

    lines[line_to_start:line_to_start] = f'                    <div class="grid-item wide tall">\n\
                            <div data-background="">\n\
                                <!-- lightbox expand link -->\n\
                                <a href="{new_gallery}">\n\
                                    <img src="{thumb_img}">\n                           </a >\n\
                                <!-- title -->\n\
                                <div class = "no-redirect">\n\
                                                    <b> <h4>{gallery_name}</h4> </b>\n\
                                </div>\n\
                            </div>\n\
                        </div>\n ' '\n '

    with open(gallery_inter, 'w', encoding='utf8') as file:
        file.writelines(lines)

thumb_mkr()

</code>```

So running thumb_maker.py in VS code works fine, double clicking it in the folder - not really.
If you want to try the whole thing yourself you will need:
A sample URL (use this): https://api.imgur.com/post/v1/albums/rUHnbuZ?client_id=546c25a59c58ad7&include=media%2Cadconfig%2Caccount

And these two files: files

I also tried to make the code in page_maker.py a separate function and make another file that just calls the 2 functions but still doesn't work when I double click.

Body:
First, I am still a noob so please bear with me.
I have written some code that helps automate links formation and gallery creation for a website.
It all seems to work just fine when I run it in VS code, but when I try to double click the thumb_maker.py file only the first "module" seems to be executed. When I double click it, a window opens and I get asked to input the URL which is what should happen, but then the window closes and nothing else happens. There should be 3 inputs in total: Enter Gallery URL:, Choose gallery FILE name, and Choose gallery name. The code is separated in 3 "modules" (files): jpg_lister.py, page_maker.py and thumb_maker.py

(Edit from 11.01.2023) I tried it again on a different PC and it all works just fine so I suspect it's a Python installation problem on the other PC. I recently installed Invoke AI (a web based GUI for stable diffusion) on the problematic PC and it also installed Python I think, so I think it kinda messed things up. Any ideas what I can do to fix it or check my hypothesis?

here is the code for all 3:

**Code for jpg_lister.py: **

import requests

url = input("Enter Gallery URL: ")
data = requests.get(url).json()

links = []
for m in data['media']:
    links.append(m['url'])

formated_links = []

for link in links:
    formated_links.append(f'\n\
                        \n\
                    \n\
')

**code for page_maker.py: **

from jpg_lister import formated_links

line_to_start = 91  # the line we want to start at
gallery_template = "gallery-justified-fullwidth-blanc.html"

with open(gallery_template, 'r', encoding='utf8') as file:
    lines = file.readlines()

lines[line_to_start:line_to_start] = formated_links

new_gallery = "gallery-justified-fullwidth-" + \
    input("Choose gallery FILE name: ") + ".html"
with open(new_gallery, 'w', encoding='utf8') as file:
    file.writelines(lines)

**code for thumb_maker.py: **

from jpg_lister import links
from page_maker import new_gallery

def thumb_mkr():
    line_to_start = 89  # the line we want to start at
    gallery_inter = "gallery-albums-fullwidth-inter.html"

    gallery_name = input("Choose Gallery name: ")
    thumb_img = links[0]

    with open(gallery_inter, 'r', encoding='utf8') as file:
        lines = file.readlines()
    # now we have an array of lines. If we want to edit the line 89...

    lines[line_to_start:line_to_start] = f'
\n\

\n\
                                \n\
                                \n\
                                    \n                           \n\
                                \n\

\n\

{gallery_name}
 \n\

\n\

\n\

\n ' '\n '

    with open(gallery_inter, 'w', encoding='utf8') as file:
        file.writelines(lines)

thumb_mkr()

So running thumb_maker.py in VS code works fine, double clicking it in the folder - not really.
If you want to try the whole thing yourself you will need:
A sample URL (use this): https://api.imgur.com/post/v1/albums/rUHnbuZ?client_id=546c25a59c58ad7&include=media%2Cadconfig%2Caccount

And these two files: files

I also tried to make the code in page_maker.py a separate function and make another file that just calls the 2 functions but still doesn't work when I double click.


问:
Preprocess MQTT messages before ingest to InfluxDB
I'm just researching InfluxDB at this stage and got this question: is it possible to do anything with MQTT message before ingest it to InfluxDB?

I get some sensors data trough MQTT and it's in JSON format, but main parameters are coming in encrypted format as a field of the JSON and before to ingest it I need to preprocess them and extract real values. What would be the best practice to do this?

I understand that I can write my own service that subscribe to MQTT, encode the data and then send it to InfluxDb, but is it only the option? Can I extend Telegraf somehow to do this?


问:
Good ways to deal with operations that return Result when using Ndarray
Recently I've started using ndarray to handle my multi-dimentional arrays when using Rust, and I love a lot of it's convenience features, if I could just figure out one problem, it would be perfect.

Normally, when you collect an iterator over set a Results (e.g. you just did a map operation that was fallible), you can tell rust that you would like to collect it as a Result<Vec<_>, _>, instead of a Vec<Result<, _>>. This is super helpful, but as far as I can tell Ndarray's producers don't have a similar feature? What I'd like to know is how can I efficiently deal with Results when using Ndarray's Producers/when using Zip to operate over a ndarray.

All I can think to do is to either turn the ndarray into a normal iterator, which I don't want to do because the dimentionality is lost (e.g. an Array3 turns into a Vec), do some kind of second iteration after the first to find any Err variants, which seems inefficient, or just use unwrap everywhere...

I'd really appreciate any other perspectives on using ndarray, or other ways to manage multi-dimensional arrays in rust.

code-example:

let thingy: Array3 = whatever;

let output = Zip::from(thingy).and(another_thingy).map_collect(|thing1, thing2| {
    function_that_returns_result(thing1, thing2)
});

//output ends up being an Array3 of Results, where I would like an idiomatic way for it to be a Result containing an Array3
```


问:
Why is my variable undefined after I import it?
I have a function that gets the inner html of a div container.

```<code>function saveTab(el){

    let saveTabContainer = document.getElementById(el);
    module.exports.innerHTMLTabContainer = saveTabContainer.innerHTML;
}

</code>```

If I console.log the variable in this file, it returns with the appropriate value.
However, when I import it using:

```<code>let {innerHTMLTabContainer} = require('../public/javascripts/saveTab');
</code>```

the value becomes undefined.

I used

```<code>console.log(innerHTMLTabContainer);
</code>```

in my file that imports the innerHTMLTabContainer variable but it prints out "undefined".

Body:
I have a function that gets the inner html of a div container.

function saveTab(el){

    let saveTabContainer = document.getElementById(el);
    module.exports.innerHTMLTabContainer = saveTabContainer.innerHTML;
}

If I console.log the variable in this file, it returns with the appropriate value.
However, when I import it using:

let {innerHTMLTabContainer} = require('../public/javascripts/saveTab');

the value becomes undefined.

I used

console.log(innerHTMLTabContainer);

in my file that imports the innerHTMLTabContainer variable but it prints out "undefined".


问:
r mice - "sample" imputation method not working correctly
I am using mice to impute missing data in a large dataset (24k obs, 98 vars). I am using the "sample" imputation method to impute some variables (and other methods for the others - many categorical). When I check my imputed data, those variables that I've applied "sample" to are not always imputed and I have missingness in them. I know for sure that I'm applying "sample" to them (I double checked the methods), and I made sure to remove all predictors of them in the prediction matrix. From my understanding, where they are in the visit sequence shouldn't matter (but I make sure they're immediately after variables with no missingness).

I can't give you a reprex because when I try to recreate the problem, it doesn't happen and everything is imputed just fine. I tried simulating my own data and I tried subsetting the dataset to a group of the variables that I want to use the sample method on. That's part of why I'm so stumped - I coded everything the same and it worked with the subset. I didn't think that the sample method would be at all dependent on the presence of any other vars.

EDIT:
This is the code I'm using

```<code>#produce prediction matrix
pred1 <- quickpred_ext(data1, mincor = 0.08, include = "age")
pred2 <- pred1

# for vars to not be imputed, set all predictors to 0
data_no_impute <- data1 %>%
  select(contains(c("exp_", "outcome_"))) %>%
  select(sort(names(.))) %>%
  names

data_level3 <- data1 %>%
  select(contains(c("f4", "f5", "f6")),
         k22) %>%
  select(sort(names(.))) %>%
  names

pred2[data_no_impute,] <- 0
pred2[data_level3,] <- 0

#produce initial methods and visit sequence
initial <- mice(data1, max = 0, print = F, vis = "monotone",
                defaultMethod = c("pmm", "logreg", "polyreg", "polr"))

#edit methods to be blank for vars I don't want to impute, "sample" for level 3
meth1 <- initial$meth
meth2 <- meth1
meth2[data_level3] <- "sample"
meth2[data_no_impute] <- ""

visits1 <- initial$visitSequence
visits2 <- visits1
visits2 <- append(visits2, data_level3,22)

#run mice test
mice_test <- mice(data1, m = 2, print = F,
                  predictorMatrix = pred2,
                  method = meth2,
                  vis = visits2,
                  nnet.MaxNWts = 3000)

#pull second completed dataset
imput1 <- mice::complete(mice_test, 2, include = F)

#look at missingness patterns
missingness_pattern2 <- md.pattern(imput1, plot = F)
</code>```

Body:
I am using mice to impute missing data in a large dataset (24k obs, 98 vars). I am using the "sample" imputation method to impute some variables (and other methods for the others - many categorical). When I check my imputed data, those variables that I've applied "sample" to are not always imputed and I have missingness in them. I know for sure that I'm applying "sample" to them (I double checked the methods), and I made sure to remove all predictors of them in the prediction matrix. From my understanding, where they are in the visit sequence shouldn't matter (but I make sure they're immediately after variables with no missingness).

I can't give you a reprex because when I try to recreate the problem, it doesn't happen and everything is imputed just fine. I tried simulating my own data and I tried subsetting the dataset to a group of the variables that I want to use the sample method on. That's part of why I'm so stumped - I coded everything the same and it worked with the subset. I didn't think that the sample method would be at all dependent on the presence of any other vars.

EDIT:
This is the code I'm using

#produce prediction matrix
pred1 <- quickpred_ext(data1, mincor = 0.08, include = "age")
pred2 <- pred1

# for vars to not be imputed, set all predictors to 0
data_no_impute <- data1 %>%
  select(contains(c("exp_", "outcome_"))) %>%
  select(sort(names(.))) %>%
  names

data_level3 <- data1 %>%
  select(contains(c("f4", "f5", "f6")),
         k22) %>%
  select(sort(names(.))) %>%
  names

pred2[data_no_impute,] <- 0
pred2[data_level3,] <- 0

#produce initial methods and visit sequence
initial <- mice(data1, max = 0, print = F, vis = "monotone",
                defaultMethod = c("pmm", "logreg", "polyreg", "polr"))

#edit methods to be blank for vars I don't want to impute, "sample" for level 3
meth1 <- initial$meth
meth2 <- meth1
meth2[data_level3] <- "sample"
meth2[data_no_impute] <- ""

visits1 <- initial$visitSequence
visits2 <- visits1
visits2 <- append(visits2, data_level3,22)

#run mice test
mice_test <- mice(data1, m = 2, print = F,
                  predictorMatrix = pred2,
                  method = meth2,
                  vis = visits2,
                  nnet.MaxNWts = 3000)

#pull second completed dataset
imput1 <- mice::complete(mice_test, 2, include = F)

#look at missingness patterns
missingness_pattern2 <- md.pattern(imput1, plot = F)


问:
How can I build an image using dotnet/sdk6 that can also handle lambdas
So, I have been struggling to find a way to do both from a single image.
I have an executable that will need dotnet/sdk:6 image to run, but then while creating a lambda I have to pull in public.ecr.aws/lambda/dotnet:6 which does not have dotnet sdk required to run the executable. But is required to serve lambda calls

For each trigger on my lambda I want to run that executable and process some data received via the same event.

So basically I need a lambda environment that call run the executable as well as handle lambda calls.

How can I do this? Should I install the runtime manually on dotnet/sdk image? How do I make the final stage compatible with lambda executions, i.e it could handle entry points like: "HelloWorld::HelloWorld.Function::FunctionHandler"

PS: Newbie alert!

I have tried experimenting with Runtime Client, but is it the right direction? Should I install Runtime client on sdk image and that will enable it to handle lambda calls?


问:
How to change font size in figure caption in a pptx rendered by quarto and pandoc?
I am rendering powerpoint slide decks using Quarto. I am successfully theming my powerpoint slide deck using a reference doc specified in yaml and can change many slide layout attributes by changing the master slides.

However, I can't seem to find the master slide attribute that changes the caption font size. Irrespective of my changes to the master slides, the caption font under the figure always seems to be 18 pt. I would like it to be smaller.

These related posts don't (currently) solve my problem:

how to change font formatting in Quarto pptx

Changing the caption font size, color, and style in PPTX qmd

The pandoc documentation suggests that captions are styled as their own class. It's not clear to me if it would be helpful (or possible) to somehow modify the caption class with quarto when rendering the pptx.

Can you specify a custom css style sheet when rendering a powerpoint slide deck?

My MRE (I can't provide the exact template I'm using):

```<code>---
title: "Captions for Figures"
format:
  pptx:
    reference-doc: my_pptx_template.potx
    slide-level: 1
---

# Slide with Figure

![The Stack Overflow Logo](https://stackoverflow.design/assets/img/logos/so/logo-stackoverflow.png){#fig-stackoverflow}
</code>```

Body:
I am rendering powerpoint slide decks using Quarto. I am successfully theming my powerpoint slide deck using a reference doc specified in yaml and can change many slide layout attributes by changing the master slides.

However, I can't seem to find the master slide attribute that changes the caption font size. Irrespective of my changes to the master slides, the caption font under the figure always seems to be 18 pt. I would like it to be smaller.

These related posts don't (currently) solve my problem:

how to change font formatting in Quarto pptx

Changing the caption font size, color, and style in PPTX qmd

The pandoc documentation suggests that captions are styled as their own class. It's not clear to me if it would be helpful (or possible) to somehow modify the caption class with quarto when rendering the pptx.

Can you specify a custom css style sheet when rendering a powerpoint slide deck?

My MRE (I can't provide the exact template I'm using):

---
title: "Captions for Figures"
format:
  pptx:
    reference-doc: my_pptx_template.potx
    slide-level: 1
---

# Slide with Figure

![The Stack Overflow Logo](https://stackoverflow.design/assets/img/logos/so/logo-stackoverflow.png){#fig-stackoverflow}