Wednesday, July 20, 2022

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


in Prometheus, how to ignore a label in a range-vector (rate())

Posted: 20 Jul 2022 06:10 AM PDT

i'm using Prometheus. i am trying to get the rate of a counter, no matter which tenant is being processed by the server. for the rate expression i am using: rate(token_generator_http_request_count{bundle="abcd", kubernetes_name="name_abcd"}[1m]

this gives me a different value for each of my tenants. now i want to get the overall rate. i tried using: rate(token_generator_http_request_count{bundle="abcd", kubernetes_name="name_abcd"}[1m] without (tenant)

i'm getting an error. it seems Prometheus doesn't let using "without" for a range-vector function. is there a way to unify the rate (without creating a new metric which will not set a tenant label at all)

thanks

How to dynamically bind data to adaptive card template in Java

Posted: 20 Jul 2022 06:10 AM PDT

I am developing a Microsoft teams bot using java (spring boot) which send the messages to the teams users, I can sent the messages using cards. Now I am trying to dynamically generate the adaptive card. I have created the adaptive card template and I have the data, In adaptive card designer everything work fine.

The problem is there is no Java SDK for adaptive card templating, there is only C# and JavaScript SDKs https://docs.microsoft.com/en-us/adaptive-cards/templating/sdk

Using JavaScript we can simple pass the data to template to generate the card but how can I do it in java spring boot application.

Here is my template:

{  "$schema": "https://adaptivecards.io/schemas/adaptive-card.json",  "type": "AdaptiveCard",  "version": "1.3",  "body": [      {          "id": "messageBlock",          "type": "TextBlock",          "text": "${msg.message}",          "wrap": true      },      {          "id": "messageSeparator",          "type": "TextBlock",          "text": " ",          "separator": true,          "spacing": "Medium"      },      {          "id": "mediaContainer",          "type": "Container",          "$data": "${media}",          "items": [              {                  "type": "ColumnSet",                  "columns": [                      {                          "type": "Column",                          "width": "auto",                          "items": [                              {                                  "type": "Image",                                  "$when": "${not(empty(icon))}",                                  "url": "${icon}",                                  "size": "Small"                              }                          ]                      },                      {                          "type": "Column",                          "width": "stretch",                          "items": [                              {                                  "type": "TextBlock",                                  "$when": "${not(empty(fileName))}",                                  "text": "${fileName}",                                  "size": "Medium",                                  "wrap": true,                                  "weight": "Bolder",                                  "color": "Accent",                                  "height": "stretch"                              }                          ],                          "selectAction": {                              "type": "Action.OpenUrl",                              "url": "${url}",                              "title": "View"                          }                      }                  ]              },              {                  "type": "TextBlock",                  "text": " ",                  "wrap": true,                  "separator": true,                  "spacing": "Medium"              }          ]      }  ],  "actions": [      {          "$when": "${direction == 'Inbound'}",          "type": "Action.Submit",          "title": "Reply",          "data": {              "type": "task/fetch",              "submitLocation": "task/fetch"          }      }  ]  

}

and the sample data:

{  "direction": "Inbound",  "message": "test message",  "media": [      {      "url": "https://example.com/imageUrl1",      "icon" : "https://example.com/icon1",      "fileName": "file1.png",      "fileType": "png"  },  {      "url": "https://example.com/imageUrl2",      "icon" : "https://example.com/icon2",      "fileName": "image1.png",      "fileType": "png"  }  ]  

}

WD Hard disk stopped working while copying a file [closed]

Posted: 20 Jul 2022 06:09 AM PDT

I recently bought a 2TB hard disk about a month ago. Suddenly today when I was copying a file to it suddenly stopped working and started to make a noise. (It is similar to the noise hard disks make when it starts. But this just spins turning off and spinning again. (or the actuator makes it.. don't know))

So I restarted the PC and the disk was gone from the file explorer so I checked the disk manager. And this was what I greeted with (when I start the PC it made the noise for few mins and settled down)

enter image description here

I am not sure what should I do... will it erase all the data? There were some important data in that disk. Is there a safe way to fix this.

TFTP client error when trying to open the requested file

Posted: 20 Jul 2022 06:09 AM PDT

i have already posted my question on [NXP comunity forum][1] but the team says that LWIP is open source and not related to NXP. which i agree. i have the following scenario :

  • PC will run a TFTP server containing all SW files
  • MCU will run a TFTP client that will ask (by file name) the server for the flash file
  • MCU will receive the flash file and start the SW update (erase all flash memory and write).

for TFTP server i used the [TFTPD64][2] . MCU will run the client, most of the code is taking from this github [repo][3] TFTP client is started correctly on port 69, when i request a file from the server i ge the error 'Failed to open file', even though the server is poiting to it and is available

void tftp_example_init_client(void)  {    void *f;    err_t err;    ip_addr_t srv;    int ret = ipaddr_aton(LWIP_TFTP_EXAMPLE_CLIENT_REMOTEIP, &srv);    if(ret != 1)    {      printf("ipaddr_aton failed \r\n");    }        err = tftp_init_client(&tftp);    if(err != ERR_OK)    {        printf("tftp_init_client failed, error : %d \r\n", err);    }      f = tftp_open_file(LWIP_TFTP_EXAMPLE_CLIENT_FILENAME, 1);    if(f == NULL)    {       printf("failed to open file , %d \r\n", f);    }      err = tftp_get(f, &srv, TFTP_PORT, LWIP_TFTP_EXAMPLE_CLIENT_FILENAME,   TFTP_MODE_OCTET);    if(err != ERR_OK)    {        printf("tftp_get failed \r\n");    }  

}

the tftp_open_file function is defined as follow :

static void * tftp_open_file(const char* fname, u8_t is_write)  {    snprintf(full_filename, sizeof(full_filename), "%s%s", LWIP_TFTP_EXAMPLE_BASE_DIR,   fname);    full_filename[sizeof(full_filename)-1] = 0;    printf("%s \r\n",fname);    if (is_write) {      return (void*)fopen(full_filename, "wb");    } else {      return (void*)fopen(full_filename, "rb");    }  }    static void* tftp_open(const char* fname, const char* mode, u8_t is_write)  {    LWIP_UNUSED_ARG(mode);    return tftp_open_file(fname, is_write);  }  

Thank you. [1]: https://community.nxp.com/t5/S32K/Update-SW-via-TFTP-client/m-p/1492444/emcs_t/S2h8ZW1haWx8dG9waWNfc3Vic2NyaXB0aW9ufEw1VEszSkZHQTk5MFZSfDE0OTI0NDR8U1VCU0NSSVBUSU9OU3xoSw#M16524 [2]: https://tftpd64.software.informer.com/ [3]: https://github.com/nicedayzhu/STM32F4_TFTPClient_IAP/blob/master/BSP/tftp_example.c

I can't see anything wrong with my code but I am getting an invalid syntax error [closed]

Posted: 20 Jul 2022 06:09 AM PDT

if Guessp1 == Player1_secretword:      print(" player 1 guessed correctly, the secret word was " + Player1_secretword)      print(" the number of guesses by player 1: ")      print(nogp1)      print(" The number of hints taken by player 1:")      print(noghp1    while Guessp2 != Player1_secretword:      Guessp2 = input("player 2, guess your secret word: ")      nogp2 += 1      if Guessp2 != Player2_secretword:          hint2 = input("would you like a hint? (Y/N): ")          if hint2 in ["yes", "y", "Y"]:              hintcharecter = Player2_secretword[0]              print("hint: " + hintcharecter)              noghp2 += 1          else:              print("ok continue")  

The error that comes up is the following:

while Guessp2 != Player1_secretword:      ^  SyntaxError: invalid syntax  

I have a problem with adaptation, I uploaded the gif to the mobile version, it fits perfectly, but the dimensions are broken on the tablet

Posted: 20 Jul 2022 06:09 AM PDT

I have a problem with adaptation, I uploaded the gif to the mobile version, it fits perfectly, but the dimensions are broken on the tablet, how can I solve this? photo, no errors

photo, errors

Gets all the records from Table A if the id field does not exist in table B and if it exists it is different from the date field - mysql

Posted: 20 Jul 2022 06:09 AM PDT

I need to get a query from two tables that is conditional. I want to say, I need to obtain the "id_product" field from table A that does not exist in table B, and if it exists in table B it has to be that the "date" field in table A is different from the "date" field in the table B.

Table A

id_product,date,description...  3, 2022-07-19  4, 2022-07-20  5, 2022-07-20  

Table B

id_product,date,details...  3, 2022-07-20  5, 2022-07-20  

The result of the query would be:

id_product,date  3, 2022-07-20  4, 2022-07-20  

Unhandled Exception: MissingPluginException(No implementation found for method openEditor on channel video_editor_sdk)

Posted: 20 Jul 2022 06:10 AM PDT

[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: MissingPluginException(No implementation found for method openEditor on channel video_editor_sdk)

My project in this error .

Use This Dependency : video_editor_sdk: ^2.6.0

Please fast This Error Solution .. StackOverflow Community

Javascript code only works when debugging

Posted: 20 Jul 2022 06:09 AM PDT

var selectedLetter = "global right now";    function GetLink() {    fetch("https://random-word-api.herokuapp.com/word")      .then(        r => {          if (r.status != 200)            return;          r.json().then(            c => {              for (let i = 0; i < c[0].length; i++) {                p = document.createElement("div");                p.innerHTML = "_";                if (i == 0) {                  p.setAttribute("id", "first");                }                p.classList.add("word");                document.querySelector("#word").appendChild(p)              }              });        }      )  }    function SetupKeyboard() {    letters = document.getElementsByClassName("word");    selectedLetter = document.getElementById("first");  }    window.addEventListener('load', () => {    GetLink();    SetupKeyboard();  });
html,  body,  #wrapper {    height: 100%;    width: 100%;  }    #title {    font-size: xx-large;    text-align: center;  }    #word {    font-size: xx-large;    text-align: center;  }    .word {    display: inline;    margin: 2px;    background-color: beige;  }
<!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>Hangman</title>    <link rel="stylesheet" href="style.css">    <script src="index.js"></script>  </head>    <body>    <div id="title">      Hangman    </div>    <div id="word">      </div>  </body>    </html>

It seems to be a simple problem but it's driving me insane.

function SetupKeyboard()  {    letters=document.getElementsByClassName("word");        selectedLetter=document.getElementById("first");  }  

I need the selected letter to be the first element of the "letters" array but for some reason selectedLetter=letters[0] gave back "undefined". I tried this approach too and it's the same problem. I am obviously missing something.

When I debug the code it works properly and the console logs everything as expected. When NOT in debugger the value of selectedLetter is "undefined". Also, the problem is gone when I call the function manually through browser console as well.

I know the problem is not in the DOM not existing because I run it all like this:

window.addEventListener('load', ()=>{      GetLink();      SetupKeyboard();  });  

WEB Firbase Remote Config - fetchAndActivate method fetching all the values from remote config, I want only single value to be fetched

Posted: 20 Jul 2022 06:10 AM PDT

Here is my code snippet which I am using, everything is working as expected but only issue is that fetchAndActivate method fetches all value from remote and caches them. Is there any way of feching and activating only single value from remote config?

fetchAndActivate(remoteConfig).then(        _res => {          const val = getValue(remoteConfig, "MPEmptyCartRecos");          const value = JSON.parse(val.asString());          this.setState({widgetConfigResponse: value});      },      err => {          console.log("error >>>>>", err);      }      );  

Unable to access/get value of abstract (base) class properties from derived class - TypeScript

Posted: 20 Jul 2022 06:09 AM PDT

I have 2 classes - one is abstract and another class is extending it. In ABSTRACT class I have some public/protected properties which ARE initialized in constructor. Let it be abstract Parent and Child extends Parent

Questions:

  1. Why, when I am trying to get value of the properties of abstract class like: super.somePropertyOfParent it is always UNDEFINED, but when I call it like: this.somePropertyOfParent it HAS value? Logically, super constructor is always called first, so these fields should be initialized first of all.

  2. I have 2 BehaviourSubjects (countryValue, languageValue) in my Parent abstract class, which are initialized with some 'initial value' in constructor. In Child class in OnInit method (which obviously called after Parent constructor) I am subscribing to Parent's BehaviourSubjects like: this.countryValue.subscribe(...) and it receives the 'INITIAL' value. Then in Parent's class ngOnChange method calls subject.next(...), but Child doesn't receive new value...why?

P.S. if make BehaviourSubject properties STATIC and refer to the ClassName.property - everything works fine.

Please see code below:

@Directive()  export abstract class IbCustomElementComponent implements OnChanges{      @Input('data-country') country = '';    @Input('data-language') language = '';      public countryValue:BehaviorSubject<string>;    public languageValue:BehaviorSubject<string>;           protected constructor(public translateService: TranslateService) {      this.countryValue = new BehaviorSubject<string>('initial');      this.languageValue = new BehaviorSubject<string>('initial');    }      abstract customElementReady(changes: SimpleChanges): void;      ngOnChanges(changes: SimpleChanges) {        if (this.country && this.language) {        this.translateService.use(this.country.toLocaleLowerCase() + '-' + this.language);        this.customElementReady(changes);        this.countryValue.next(this.country);        this.languageValue.next(this.language);      }    }  }  

export class CustomerCardsComponent extends IbCustomElementComponent implements OnInit {        displayedColumns: string[] = ['fieldName', 'value'];      CARD_DATA: CardData[][] = [];      dataSource = this.CARD_DATA;      cards: Card[] = [];      currentCustomer : Customer = new Customer();        constructor(private customerListService: CustomerListService, public override translateService: TranslateService) {      super(translateService);    }      ngOnInit(): void {      this.countryValue.subscribe(c=>{        this.currentCustomer.bic = Bic[c.toUpperCase()];        if(this.currentCustomer.bic){          this.getCustomerCards(this.currentCustomer)        }      })    }  }  

How to add tailwind css with quasar

Posted: 20 Jul 2022 06:09 AM PDT

hi everyone I am trying to integrate tailwind in latest quasar version (3.5.4) i have installed tailwind using npm install tailwindcss after that i have added requier('tailwind') in .postcssrc.js but it gives an error TypeError: Cannot read properties of undefined (reading 'config') tailwind typescript

datastudio metric based on dimension value

Posted: 20 Jul 2022 06:10 AM PDT

I have a metric called 'Sales' and a dimension called 'Paid' where the value is true/false

I am trying to show 2 columns within one table in datastudio - one is Sales where the dimension value is true, the other is Sales where the dimension value is false.

for example, the data looks like this

Fully Paid Sales
TRUE 100
FALSE 200
TRUE 300

I am trying to get to a table like this using a calculated field

Sales Paid True Sales Paid False
400 200

I have tried a number of things within calculated fields using case but cannot get it to work such as

CASE      WHEN Fully Paid = "TRUE" THEN "Sales"  END  

I ideally don't want to go down the route of 2 tables with filters on them.

Thanks

Call to a member function delete() on string

Posted: 20 Jul 2022 06:09 AM PDT

So I get an error when I want to delete the cart, the error is Call to a member function delete() on string. I use groupby because so I can add up the total_product that matches the user_id and store_id. How to solve it?

Controller

public function storebilling(Request $request, $id)  {    $cart = Cart::where('user_id', Auth::user()->id)->where('store_id', $id)->get();  $carts = $cart->groupBy(fn ($i) => $i->Product->Store->name);      $orders = Orders::where('user_id', Auth()->user()->id)->latest()->get();    if ($carts) {      foreach ($carts as $cart => $items) {          foreach($items as $item){              foreach ($orders->take(1) as $order) {                  OrderDetails::create([                      'product_id' => $item->product_id,                      'order_id' => $order->id,                      'price' => $item->product->price * ((100 - $item->product->discount) / 100),                      'qty' => $item->qty,                      'discount' => $item->product->discount                  ]);              }          }          $cart->delete();      }  } else {      return redirect('/cart');  }  

So, The error in line $cart->delete(); How to solve it?

A required bean can not be found during tests / No bean named 'entityManagerFactory' available

Posted: 20 Jul 2022 06:09 AM PDT

I am developing a small app just to try Spring boot on my own. It has five different modules (eclipse projects):

model--contains entity classes, DTO's and mappers to switch between them

data--contains repositories

service--contains services and their implementations

reserve-management--contains the controller for the reservations and the spring app itself

person-management--contains the controller for the people data and the spring app itself

If I start either of the apps, they run just fine but when developing tests for them I always get this exception:

java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132) ~[spring-test-5.3.21.jar:5.3.21] at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124) ~[spring-test-5.3.21.jar:5.3.21] at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190) ~[spring-test-5.3.21.jar:5.3.21] at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132) ~[spring-test-5.3.21.jar:5.3.21] at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248) ~[spring-test-5.3.21.jar:5.3.21] at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:138) ~[spring-test-5.3.21.jar:5.3.21] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$8(ClassBasedTestDescriptor.java:363) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:368) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$9(ClassBasedTestDescriptor.java:363) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) ~[na:na] at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) ~[na:na] at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655) ~[na:na] at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na] at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na] at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312) ~[na:na] at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) ~[na:na] at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) ~[na:na] at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) ~[na:na] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:362) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:283) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:282) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:272) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at java.base/java.util.Optional.orElseGet(Optional.java:369) ~[na:na] at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:271) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:102) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:101) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:66) ~[junit-jupiter-engine-5.8.2.jar:5.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90) ~[junit-platform-engine-1.8.2.jar:1.8.2] at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) ~[na:na] at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) ~[junit-platform-engine-1.8.2.jar:1.8.2] at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) ~[na:na] at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) ~[junit-platform-engine-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:95) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:91) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:60) ~[junit-platform-launcher-1.8.2.jar:1.8.2] at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98) ~[.cp/:na] at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40) ~[.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529) ~[.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756) ~[.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452) ~[.cp/:na] at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210) ~[.cp/:na] Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'reservesServiceImpl': Unsatisfied dependency expressed through field 'reserveRepo'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.hotel.data.reserve.ReservesRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:639) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.21.jar:5.3.21] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.21.jar:5.3.21] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.1.jar:2.7.1] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.1.jar:2.7.1] at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.1.jar:2.7.1] at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:132) ~[spring-boot-test-2.7.1.jar:2.7.1] at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) ~[spring-test-5.3.21.jar:5.3.21] at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ~[spring-test-5.3.21.jar:5.3.21] ... 71 common frames omitted Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.hotel.data.reserve.ReservesRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1801) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) ~[spring-beans-5.3.21.jar:5.3.21] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656) ~[spring-beans-5.3.21.jar:5.3.21] ... 90 common frames omitted

It also tells me that I should add a bean of type ReservesRepository in my configuration.

I have removed methods from classes for brevity.

Test class and pom.xml in reserve-management project:

      package com.hotel.reservemanagement.service;            import static org.junit.jupiter.api.Assertions.assertEquals;            import java.util.Optional;            import org.junit.jupiter.api.Test;      import org.springframework.beans.factory.annotation.Autowired;        import org.springframework.boot.test.context.SpringBootTest;      import org.springframework.context.annotation.ComponentScan;      import org.springframework.transaction.annotation.Transactional;            import com.hotel.model.reserve.Reserve;      import com.hotel.service.reserve.ReservesServiceImpl;            @SpringBootTest(classes = ReservesServiceImpl.class)      @ComponentScan("com.hotel.data")      public class ReservesServiceTests {                    @Autowired          private ReservesServiceImpl reservesService;                    @Test          @Transactional          void testSave () {              Optional<Reserve> reserve = this.reservesService.findById(2L);              reserve.get().setAdults(3L);              this.reservesService.save(reserve.get());              Optional<Reserve> reserveResult = this.reservesService.findById(2L);                            assertEquals(3L, reserveResult.get().getAdults());          }      }       
      <?xml version="1.0" encoding="UTF-8"?>          <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"              xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">              <modelVersion>4.0.0</modelVersion>              <parent>                  <groupId>org.springframework.boot</groupId>                  <artifactId>spring-boot-starter-parent</artifactId>                  <version>2.7.1</version>                  <relativePath/> <!-- lookup parent from repository -->              </parent>              <groupId>com.hotel</groupId>              <artifactId>reserve-management</artifactId>              <version>0.0.1-SNAPSHOT</version>              <name>reserve-management</name>              <description>Hotel reserves management</description>              <properties>                  <java.version>11</java.version>              </properties>              <dependencies>                                <dependency>                      <groupId>com.oracle.database.jdbc</groupId>                      <artifactId>ojdbc8</artifactId>                      <scope>runtime</scope>                  </dependency>                            <dependency>                       <groupId>org.springframework.boot</groupId>                      <artifactId>spring-boot-starter-test</artifactId>                      <scope>test</scope>                  </dependency>                                    <dependency>                      <groupId>com.hotel</groupId>                      <artifactId>model</artifactId>                      <version>0.0.1-SNAPSHOT</version>                  </dependency>                                    <dependency>                      <groupId>com.hotel</groupId>                      <artifactId>service</artifactId>                      <version>0.0.1-SNAPSHOT</version>                  </dependency>              </dependencies>                        <build>                  <plugins>                      <plugin>                          <groupId>org.springframework.boot</groupId>                          <artifactId>spring-boot-maven-plugin</artifactId>                      </plugin>                  </plugins>              </build>                    </project>    

Reserves service, its implementation and pom.xml in service project:

      package com.hotel.service.reserve;            public interface ReservesService {          //some code here          }    
      package com.hotel.service.reserve;            import org.springframework.beans.factory.annotation.Autowired;      import org.springframework.stereotype.Service;            import com.hotel.data.reserve.ReservesRepository;                  @Service      public class ReservesServiceImpl implements ReservesService{                    @Autowired          private ReservesRepository reserveRepo;          //some code here      }    
      <?xml version="1.0" encoding="UTF-8"?>      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">          <modelVersion>4.0.0</modelVersion>          <parent>              <groupId>org.springframework.boot</groupId>              <artifactId>spring-boot-starter-parent</artifactId>              <version>2.7.1</version>              <relativePath/> <!-- lookup parent from repository -->          </parent>          <groupId>com.hotel</groupId>          <artifactId>service</artifactId>          <version>0.0.1-SNAPSHOT</version>          <name>service</name>          <description>Services for Hotel application</description>          <properties>              <java.version>11</java.version>          </properties>          <dependencies>              <dependency>                  <groupId>org.springframework.boot</groupId>                  <artifactId>spring-boot-starter-web</artifactId>              </dependency>              <dependency>                  <groupId>org.springframework.boot</groupId>                  <artifactId>spring-boot-starter-web-services</artifactId>              </dependency>                    <dependency>                  <groupId>org.springframework.boot</groupId>                  <artifactId>spring-boot-starter-test</artifactId>                  <scope>test</scope>              </dependency>              <dependency>                  <groupId>com.hotel</groupId>                  <artifactId>data</artifactId>                  <version>0.0.1-SNAPSHOT</version>              </dependency>          </dependencies>                <build>              <plugins>                  <plugin>                      <groupId>org.apache.maven.plugins</groupId>                      <artifactId>maven-jar-plugin</artifactId>                  </plugin>              </plugins>          </build>            </project>    

Repository class and pom.xml in data project:

      package com.hotel.data.reserve;            import org.springframework.data.jpa.repository.JpaRepository;      import org.springframework.stereotype.Repository;            import com.hotel.model.reserve.Reserve;            @Repository      public interface ReservesRepository extends JpaRepository<Reserve, Long> {          //some code here      }    
      <?xml version="1.0" encoding="UTF-8"?>      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">          <modelVersion>4.0.0</modelVersion>          <parent>              <groupId>org.springframework.boot</groupId>              <artifactId>spring-boot-starter-parent</artifactId>              <version>2.7.1</version>              <relativePath/> <!-- lookup parent from repository -->          </parent>          <groupId>com.hotel</groupId>          <artifactId>data</artifactId>          <version>0.0.1-SNAPSHOT</version>          <name>data</name>          <description>Data for Hotel application</description>          <properties>              <java.version>11</java.version>          </properties>          <dependencies>              <dependency>                  <groupId>com.hotel</groupId>                  <artifactId>model</artifactId>                  <version>0.0.1-SNAPSHOT</version>              </dependency>                            <dependency>                  <groupId>com.h2database</groupId>                  <artifactId>h2</artifactId>                  <scope>runtime</scope>              </dependency>                        </dependencies>                <build>              <plugins>              </plugins>          </build>            </project>  

Scrape html table row with Beautiful Soup

Posted: 20 Jul 2022 06:09 AM PDT

I'm trying to scrape an html table with bs4, but my code is not working. I'd like to get the tds row data information so that I can write them in a csv file. this is my html code:

<table class="sc-jAaTju bVEWLO">      <thead>          <tr>              <td width="10%">Rank</td>              <td>Trending Topic</td>              <td width="30%">Tweet Volume</td>          </tr>          </thead>          <tbody>          <tr>              <td>1</td>              <td><a href="http:///example.com/search?q=%23One" target="_blank" without="true" rel="noopener noreferrer">#One</a></td>              <td>1006.4K tweets</td>          </tr>          <tr>              <td>2</td>              <td><a href="http:///example.com/search?q=%23Two" target="_blank" without="true" rel="noopener noreferrer">#Two</a></td>              <td>1028.7K tweets</td>          </tr>          <tr>              <td>3</td>              <td><a href="http:///example.com/search?q=%23Three" target="_blank" without="true" rel="noopener noreferrer">#Three</a></td>              <td>Less than 10K tweets</td>          </tr>      </tbody>  </table>  

This is my first try:

url = requests.get(f"https://www.exportdata.io/trends/italy/2020-01-01/0")  soup = BeautifulSoup(url.text, "html.parser")    table = soup.find_all("table", attrs={"class":"sc-jAaTju bVEWLO"})    

And my second one:

tables = soup.find_all('table')       for table in tables:      td = tables.td.text.strip()    

But neither are working. What am I missing? Thank you

why my async code is not executing inspite of being the free call stack

Posted: 20 Jul 2022 06:10 AM PDT

As per my knowledge async code is executed when the call stack is empty and execution of the async code is finished in web API

  • But In a given code why my async code which is setTimeout function and Promise which resolve quickly -- is not getting executed at the mark point <---

  • at this point call stack is also empty and async code might also have been executed

  • Function fu() is used as a delay so that async code should executed until<----

but output is

after 1   after 1  Test End  Resolve promise1  0 sec timer  

console.log('test start');  setTimeout(() => console.log('0 sec timer'), 0);  Promise.resolve('Resolve promise1').then(res => {    mk = 20;    console.log(res);  });  fu();  fu();  // <<---------    console.log('Test End');

As I am in learning stage of JavaScript so please tell me if I am lagging in tech detail of asynchronous js

Itertools Groupby returns None when appending list to dict

Posted: 20 Jul 2022 06:09 AM PDT

I have the following code on which I'm grouping by a value in a particular dictionary:

from itertools import groupby  def group_owners(files):      # sort data before using groupby      files = dict(sorted(files.items()))        # create the groupby which will return an iterator containing a key (string) and a group which itself is a iterator      # in order to store this group iterator is necessary to initialize an empty data strcturure first      iterator = groupby(files,lambda x: files[x])            groups = []        return {k:groups.append(list(g)) for k,g in iterator}                if __name__ == "__main__":          files = {          'Input.txt': 'Randy',          'Code.py': 'Stan',          'Input2.txt': 'James',          'Output.txt': 'Randy'      }         print(group_owners(files))  

This code returns me that:

{'Stan': None, 'Randy': None, 'James': None}  

I was expecting a list in place of None with the groups for each key, in fact when I debug I can see that a list of lists is being created but at the end of program None is returned. I also would like to have only a flat list and not a list of lists.

My expected output is:

{'Stan': ['Code.py'], 'Randy': ['Input.txt','Output.txt'], 'James': 'Input2.txt'}  

If I use instead:

{k:list(g) for k,g in iterator} what I get is:

{'Stan': ['Code.py'], 'Randy': ['Output.txt'], 'James': ['Input2.txt']}  

I believe because of this fact, quoting form Python docs:

The returned group is itself an iterator that shares the underlying iterable with groupby(). Because the source is shared, when the groupby() object is advanced, the previous group is no longer visible. So, if that data is needed later, it should be stored as a list:

https://docs.python.org/3/library/itertools.html#itertools.groupby

Power BI - Filtering model on latest version of all attributes of all dimensions through DAX

Posted: 20 Jul 2022 06:09 AM PDT

I have a model that's comprised of multiple tables containing, for every ID, multiple rows with a valid_from and valid_to dates.

This model has one table in that is linked to every other table (a table working as both a fact and a dimension).

This fact has bi-directional cross filtering with the other tables.

I also have a date dimension that is not linked to any other table.

I want to be able to calculate the sum of a column in this table in the following way:

  • If a date range is selected, I want to get the sum of the latest value per ID from the fact able that is before the max selected date from the date dimension.

  • If no date is selected, I want to get the sum of the current version of the value per ID.

This comes down to selecting the latest value per ID filtered on the dates.

Because of the nature of the model (bi-directional with the fact/dimension table), I want to have the latest version of any attribute from any dimension selected in the visual.

Here's an data example and the desired outcome:

fact/dimension table:

ID Valid_from Valid_to Amount SK_DIM1 SK_DIM2
1 01-01-2020 05-12-2021 50 1234 6787
1 05-13-2021 07-31-2021 100 1235 6787
1 08-01-2021 12-25-2021 100 1236 6787
1 12-26-2021 12-31-2021 200 1236 6787
1 01-01-2022 12-31-9999 200 1236 6788

Dimension 1:

ID SK Valid_from Valid_to Name
1 1234 10-20-2019 06-01-2021 Name 1
1 1235 06-02-2021 07-31-2021 Name 2
1 1236 08-01-2021 12-31-9999 Name 3

Dimension 2:

ID SK Valid_from Valid_to Name
1 6787 10-20-2019 12-31-2021 Name 1
1 6788 01-01-2022 12-31-9999 Name 2

My measure is supposed to do the following:

  • If no date is selected than the result will be a matrix like the following:
Dim 1 Name Dim 2 Name Amount Measure
Name 3 Name 2 200
  • If July 2021 is selected than the result will be a matrix like the following:
Dim 1 Name Dim 2 Name Amount Measure
Name 2 Name 1 100

So the idea here is that the measure would filter the fact table on the latest valid value in the selected date range, and then the bi-directional relationships will filter the dimensions to get the corresponding version to that row with the max validity (last valid row) in the selected range date.

I have tried to do the following two DAX codes but it's not working:

Solution 1: With this solution, filtering on other dimensions work and I get the last version in the selected date range for all attributes of all used dimensions. But the problem here is that the max valid from is not calculated per ID, so I only get the max valid from overall.

Amount Measure=  VAR _maxSelectedDate = MAX(Dates[Dates])  VAR _minSelectedDate = MIN(Dates[Dates])  VAR _maxValidFrom =       CALCULATE(          MAX(fact[valid_from]),          DATESBETWEEN(fact[valid_from], _minSelectedDate, _maxSelectedDate)          || DATESBETWEEN(fact[valid_to], _minSelectedDate, _maxSelectedDate)      )    RETURN  CALCULATE(      SUM(fact[Amount]),      fact[valid_from] = _maxValidFrom  )  

Solution 2: With this solution, I do get the right max valid from per ID and the resulting number is correct, but for some reason, when I use other attributes from the dimensions, it duplicates the amount for every version of that attribute. The bi-directional filtering does not work anymore with Solution 2.

Amount Measure=  VAR _maxSelectedDate = MAX(Dates[Dates])  VAR _minSelectedDate = MIN(Dates[Dates])  VAR _maxValidFromPerID =       SUMMARIZE(          FILTER(              fact,              DATESBETWEEN(fact[valid_from], _minSelectedDate, _maxSelectedDate)              || DATESBETWEEN(fact[valid_to], _minSelectedDate, _maxSelectedDate)          ),          fact[ID],          "maxValidFrom",          MAX(fact[valid_from])      )    RETURN      CALCULATE(          SUM(fact[Amount]),          TREATAS(              _maxValidFromPerID,              fact[ID],              fact[valid_from]          )      )  

So if somebody can explain why the bi-directional filtering doesn't work anymore that will be great, and also, more importantly, if you have any solution to have both the latest value per ID and still keep filtering on other attributes, that would be great!

Sorry for the long post, but I thought it's best to give all the details for a complete understanding of my issue, this has been picking my brain since few days now and I'm sure I'm missing something stupid but I turned to this community for help because I cannot seem to be able to find a solution!

Thank you very much in advance for any help!

Content cut on the right in a responsive design

Posted: 20 Jul 2022 06:10 AM PDT

I'm re-creating a YouTube page using media query. However, when I change the size of the browser, I find that on the right side, some content is always cut. I used grid for the blocks. I tried to set some margin in body, but it didn't work.

Since I couldn't upload the entire code, I re-created the problem. My code is below

The image shows what I mean. content partially hiding on the right

.thumbnail-1 {    width: 100%;  }    .video-info-grid {    display: grid;    grid-template-columns: 50px 1fr;  }    .video-info {    display: inline-block;    width: 250px;  }    .thumbnail-row {    margin-bottom: 8px;    position: relative;  }    .video-grid {    display: grid;    grid-template-columns: 1fr 1fr 1fr;    column-gap: 16px;    row-gap: 40px;  }    @media (max-width: 800px) {    .video-grid {      grid-template-columns: 1fr 1fr;    }  }    @media (min-width: 1199px) and (max-width: 801px) {    .video-grid {      grid-template-columns: 1fr 1fr 1fr;    }  }    @media (min-width: 1200px) {    .video-grid {      grid-template-columns: 1fr 1fr 1fr 1fr;    }  }    @media (min-width: 800px) {    .video-info {      width: 350px;    }    .video-title {      font-size: 16px;      line-height: 24px;    }    .video-author,    .video-stats {      font-size: 14px;    }  }
<div class="video-grid">    <div class="video-preview">      <div class="thumbnail-row">        <img class="thumbnail-1" src="images/thumbnail-2.webp" />      </div>        <div class="video-info-grid">        <div class="channel-picture"></div>        <div class="video-info"></div>      </div>    </div>      <div class="video-preview">      <div class="thumbnail-row">        <img class="thumbnail-1" src="images/thumbnail-2.webp" />      </div>        <div class="video-info-grid">        <div class="channel-picture"></div>        <div class="video-info"></div>      </div>    </div>      <div class="video-preview">      <div class="thumbnail-row">        <img class="thumbnail-1" src="images/thumbnail-2.webp" />      </div>        <div class="video-info-grid">        <div class="channel-picture"></div>        <div class="video-info"></div>      </div>    </div>      <div class="video-preview">      <div class="thumbnail-row">        <img class="thumbnail-1" src="images/thumbnail-2.webp" />      </div>        <div class="video-info-grid">        <div class="channel-picture"></div>        <div class="video-info"></div>      </div>    </div>  </div>

Getting spotbug issue type SE_TRANSIENT_FIELD_NOT_RESTORED

Posted: 20 Jul 2022 06:09 AM PDT

I have one listner class 'A', which implements interface 'B' and 'B' extends Serializable class.

Now in class 'A',

  1. If I declare logger as transient as below:

    private final transient Logger logger = LoggerFactory.getLogger(getClass());

then spotbug reports error as below:

logger is transient but isn't set by deserialization  
  1. If I declare logger as non-transient

    private final Logger logger = LoggerFactory.getLogger(getClass());

m getting below error:

Make "logger" transient or serializable.  

how to resolve this problem ?

Transform reorder timestamps in dataframe - R

Posted: 20 Jul 2022 06:09 AM PDT

I have the following table in R:

S <- c("A","A","A","B","B","B","C","C","C")  TS <- c(1,1,1,2,2,2,3,3,3)  f1 <- c(10,20,30,15,25,35,17,27,37)  p <- c(100,200,300,150,250,350,170,270,370)    df <- data.frame(S, TS, f1, p)  

So it looks like that:

S TS f1 p
A 1 10 100
A 2 20 200
A 3 30 300
B 1 15 150
B 2 25 250
B 3 35 350
C 1 17 170
C 2 27 270
C 3 37 370

Now I want to transform my dataframe so that I have unique values for TS (timestamps) for every row and binded my variables right to it, like this:

TS SA_f1 pA SB_f1 pB SC_f1 pC
1 10 100 15 150 17 170
2 20 200 25 250 27 270
3 30 300 35 250 37 370

What is the most elegant way doing this?

waves from selected pixel (openGL C++)

Posted: 20 Jul 2022 06:09 AM PDT

I've created a program that draws a waving flag and I want to add a functionality that will create new wave on selected pixel, but I can't make it start where I want it to start an that even make the flag stop waving (prob. because of synced sin).

Here's my display func.

const int W = 800;  const int H = 600;  // simulates Frame Buffer  unsigned char pixels[H][W][3] = { 0 }; // 3 is for RGB      void display()      {          glClear(GL_COLOR_BUFFER_BIT); // clean frame buffer                createFlag();          int i, j;          double dist;          offset += 0.25;          for (i = 0; i < H; i++)              for (j = 0; j < W; j++)              {                  dist = sqrt(pow(i + H / 2.0, 2) + pow(j + W / 2.0, 2));                  pixels[i][j][0] += 135 + 55 * (1 + 1 * sin(dist / 25 - offset)) / 2; // red                  pixels[i][j][1] += 135 + 85 * (1 + 1 * sin(dist / 25 - offset)) / 2; // green                  pixels[i][j][2] += 135 + 105 * (1 + 1 * sin(dist / 25 - offset)) / 2; // blue                    }          // draws the matrix pixels          glDrawPixels(W, H, GL_RGB, GL_UNSIGNED_BYTE, pixels);                glutSwapBuffers(); // show all      }  

And here is my mouse func.

void mouse(int button, int state, int x, int y)  {      if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)      {          double dist;          offset += 0.1;          for (y = 0; y < H; y++)              for (x = 0; x < W; x++)              {                  dist = sqrt(pow(H/2.0 -(H - y), 2) + pow(W/2.0 -x, 2)); //problem is prob. here                  pixels[y][x][0] += 135+ 55 * (1 + 1 * sin(dist / 50.0 - offset)) / 2; // red                  pixels[y][x][1] += 135+ 85 * (1 + 1 * sin(dist / 50.0 - offset)) / 2; // green                  pixels[y][x][2] += 135+105 * (1 + 1 * sin(dist / 50.0 - offset)) / 2; // blue                  if (offset < 0.3)                      offset += 0.05;              }      }  }  

Store user data in Wordpress

Posted: 20 Jul 2022 06:10 AM PDT

Short story: I need a hint how to store user details when he/she creates an account on my site (inbanat.ro). I created a custom registration form (no plugin) but the user details are not saved. After the user fills in all the details, the profile is created, but user details are not saved. Any advice is welcomed.

enter image description here

C++/WinRT: Setting value of DisplayMemberPath in XAML for Combobox

Posted: 20 Jul 2022 06:09 AM PDT

I want to use a struct as item type of a combobox based on the following code:

MyUserControl.idl:

namespace my_app  {      struct Info {            String Id;          String DisplayName;      };        [default_interface]      runtimeclass MyUserControl : Microsoft.UI.Xaml.Controls.UserControl      {          MyUserControl();      }  }    

MyUserControl.xaml:

...  <ComboBox x:Name="cbInfo" DisplayMemberPath="DisplayName"/>  ...  

MyUserControl.xaml.cpp:

void MyUserControl::SetInfo()   {      ...      Info firstInfo = Info();      firstInfo.Id = L"First identifier";      firstInfo.DisplayName = L"First display name";      cbInfo().Items().Append(winrt::box_value(firstInfo) );        Info secondInfo = Info();      secondInfo.Id = L"Second identifier";      secondInfo.DisplayName = L"Second display name";      cbInfo().Items().Append(winrt::box_value(secondInfo) );      ...  }           

The code compiles and runs, but the items in the combo box are displayed with an empty string. If I omit the attribute DisplayMemberPath in the XAML file, than for each item the following string is displayed:

Windows.Foundation.IReference`<my_app.Info>

How do I make the DisplayName value of the Info struct appear?

Update:

To avoid possible problems caused by boxing, I implemented the item type as a Windows Runtime Component for testing purposes:

InfoItem.idl:

namespace my_app  {      [default_interface]      runtimeclass InfoItem       {          InfoItem();          String Id;          String DisplayName;      }  }  

InfoItem.h:

#pragma once    namespace winrt::my_app::implementation  {      struct InfoItem : InfoItem T<InfoItem>      {          InfoItem() = default;            hstring Id();          void Id(hstring const& value);          hstring DisplayName();          void DisplayName(hstring const& value);        private:          hstring mId;          hstring mDisplayName;      };  }    namespace winrt::my_app::factory_implementation  {      struct InfoItem : InfoItem T<InfoItem, implementation::InfoItem>      {      };  }  

InfoItem.cpp

#include "pch.h"  #if __has_include("InfoItem.g.cpp")  #include "InfoItem.g.cpp"  

No comments:

Post a Comment