Tuesday, August 17, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Which system is this website built in and does it contain custom features

Posted: 17 Aug 2021 08:00 AM PDT

Can anybody tell me which system this website is built in? https://www.gobanker.dk/privatlaan

React App url parameter with S3 and CloudFront

Posted: 17 Aug 2021 08:00 AM PDT

My apologies if the information that I have provided is vague as I am not so experience with AWS and React.

I have a React Application being deployed on S3 and CloudFront as per what is suggested in the following link.

Use S3 and CloudFront to host Static Single Page Apps (SPAs) with HTTPs and www-redirects

So most of the things are working fine. I have 403 and 404 errors being redirected to index.html. However the issue comes in where I have query parameters in my url. eg. https://example.com/example?sample=123 when I enter the url in my browser the query string gets removed from the url. The end result I got is https://example.com/example I have read some articles about forwarding query parameters but it's not working for me.

AWS Documentation - Query String Parameters

Hope I will be able to get some advise here. Thanks in advance.

Deploy Content on Private IP Address?

Posted: 17 Aug 2021 08:00 AM PDT

I was reading about port forwarding which got me excited to try it myself. But I'm stuck on the first step, given an html file how can I deploy it on my laptop's private ip address with custom port?

For example, imagine my laptop's ip is 10.0.0.4

Then when typing: 10.0.0.4:9011 in the browser I want to see the contents of the file.

AddEventListener by class on dynamically created element

Posted: 17 Aug 2021 08:00 AM PDT

I would like to trigger an event when an element with a given class is clicked in pure JS. Here is a sample of my dom:

<div id="editor">      <div class="bold">bla bla</div>      <div class="bold">bla bla</div>  </div>  

The element <div class="bold">bla bla</div> are dynamically added.

I already tried:

let editor = document.getElementById('editor');  Array.prototype.filter.call( editor.getElementsByClassName('dold') , function (prismCode) {      ...  });  

None works with dynamics elements.

and:

document.getElementById('editor').querySelectorAll(".bold").forEach(() => {      ...  });  

Mapstruct - cannot find symbol: class RefDataMapperDecorator [Kotlin + Maven]

Posted: 17 Aug 2021 08:00 AM PDT

I'm having the following error when I run the command mvn clean install:

[ERROR] /Users/xxx/xxx/xxx/xxx.xxx/target/generated-sources/kapt/compile/com/xxx/xxx/xxx/xxx/DataMapperImpl.java:[10,40] cannot find symbol  [ERROR]   symbol: class DataMapperDecorator  [ERROR] /Users/xxx/xxx/xxx/xxx.xxx/target/generated-sources/kapt/compile/com/xxx/xxx/xxx/xxx/DataMapperImpl.java:[10,74] cannot find symbol  [ERROR]   symbol: class DataMapper  [ERROR] /Users/xxx/xxx/xxx/xxx.xxx/xxx/generated-sources/kapt/compile/com/xxx/xxx/xxx/api/DataMapperImpl.java:[12,19] cannot find symbol  [ERROR]   symbol:   class DataMapper  [ERROR]   location: class com.xxx.xxx.xxx.xxx.DataMapperImpl  

It seems that after mapstruct has generated the DataMapperImpl.java class it is not able to find the classes DataMapper and DataMapperDecoretor.

The code related to mapstruct is in a xxx.kt file:

//Other stuff  ...    @Mapper  @DecoratedWith(DataMapperDecorator::class)  interface DataMapper {      @Mappings(          Mapping(source = "data.value", target = "dataValue"),          Mapping(source = "data.current.value", target = "currentValue"),      )      fun toDto(data: Data) : RefDataDto  }    abstract class DataMapperDecorator : DataMapper {      @Autowired      private val delegate: DataMapper? = null        override fun toDto(data: Data): dataDto {          val dataDto = delegate!!.toDto(data)          dataDto.primaryValue = data.primaryValue?.let { CurrencyUtil.toMajor(it) }          return dataDto      }  }  

Regarding the pom files I have in the root file:

...      <properties>      ...           <org.mapstruct.version>1.4.2.Final</org.mapstruct.version>      </properties>  ...  

and this is the pom of the module where I'm using mapstruct:

...          <build>              <finalName>${project.artifactId}</finalName>              <plugins>                  <plugin>                      <groupId>org.jetbrains.kotlin</groupId>                      <artifactId>kotlin-maven-plugin</artifactId>                      <executions>                          <execution>                              <id>compile</id>                              <phase>compile</phase>                              <goals>                                  <goal>compile</goal>                              </goals>                              <configuration>                                  <sourceDirs>                                      <sourceDir>src/main/kotlin</sourceDir>                                  </sourceDirs>                              </configuration>                          </execution>                          <execution>                              <id>test-compile</id>                              <goals>                                  <goal>test-compile</goal>                              </goals>                          </execution>                          <execution>                              <id>kapt</id>                              <goals>                                  <goal>kapt</goal>                              </goals>                              <configuration>                                  <annotationProcessorPaths>                                      <annotationProcessorPath>                                          <groupId>org.mapstruct</groupId>                                          <artifactId>mapstruct-processor</artifactId>                                          <version>${org.mapstruct.version}</version>                                      </annotationProcessorPath>                                  </annotationProcessorPaths>                              </configuration>                          </execution>                      </executions>                  </plugin>                  ...              </plugins>  ...  

I hid some part of the files with dots and I'm not using the project Lombok (I saw same problems related with it we you are trying to use these projects together).

How Can I Draw a Compass with using DrawLine in C# winform

Posted: 17 Aug 2021 08:00 AM PDT

I want a draw a compass like in this picture. enter image description here

I can draw a fixed compass, but I want a change compass direction with random number. I shared my code part at below. My code is not work clearly. How can I do that. Thanks for your help.

 public void drawCompass(Graphics gr,int x1,int y1)      {            System.Drawing.Point p1 = new System.Drawing.Point();          System.Drawing.Point p2 = new System.Drawing.Point();            p1.X = 35+x1;          p1.Y = 130+y1;          p2.X = 25 + x1;          p2.Y = 150+y1;          gr.DrawLine(new Pen(Color.Lime, 3), p1, p2);            p1.X = 35+x1;          p1.Y = 130+y1;          p2.X = 45+x1;          p2.Y = 150+y1;          gr.DrawLine(new Pen(Color.Lime, 3), p1, p2);            p1.X = 35+x1;          p1.Y = 130+y1;          p2.X = 35;          p2.Y = 150;          gr.DrawLine(new Pen(Color.Lime, 3), p1, p2);          gr.DrawString("N", new System.Drawing.Font(FontFamily.GenericSansSerif, 14.0f, FontStyle.Bold), new SolidBrush(Color.Lime), p1.X-10, p1.Y + 17);            p1.X = 35+x1;          p1.Y = 170+y1;          p2.X = 35 ;          p2.Y = 190;          gr.DrawLine(new Pen(Color.Lime, 3), p1, p2);        }  

Go unmarshalling doesn't unescape backslashes

Posted: 17 Aug 2021 07:59 AM PDT

I have JSON object which after unmarshalling to a struct doesn't unescape the backslashes in the string. I tried out the following:

package main    import (      "encoding/json"      "fmt"  )    var fps = []byte(`  {      "mbyte": "\\x12\\x34\\x00\\x01\\x0a",      "define": "Data conn probe"  }`)    type dataStruct struct {      Mbyte  string `json:"mbyte"`      Define string `json:"define"`  }    func main() {      var alldata dataStruct      if err := json.Unmarshal(fps, &alldata); err != nil {          fmt.Println("error:", err.Error())      }      fmt.Printf("String: %#v | Byte: %+v\n", alldata.Mbyte, []byte(alldata.Mbyte))  }  

which outputs:

String: "\\x12\\x34\\x00\\x01\\x0a" | Byte: [92 120 49 50 92 120 51 52 92 120 48 48 92 120 48 49 92 120 48 97]  

However, the following is my desired output:

String: "\x124\x00\x01\n" | Byte: [18 52 0 1 10]  

How do I achieve this?

Why does VScode keep opening my User folder as a repo?

Posted: 17 Aug 2021 07:59 AM PDT

Every time I launch VScode I get an error "Too many commits" and on the source control tab, I see that my c:\user\ folder is synced and initialized as a repo. I closed the repo every time but I automatically starts it whenever I relaunch VScode.

This is what the git terminal shows

and there are like 5k+ changes asking to be pushed.

I checked my Github account but I don't see the folder synced as a repo. why would I even do that?

node exporter node_sockstat_TCP_alloc not coherent with node_netstat_Tcp_CurrEstab

Posted: 17 Aug 2021 07:59 AM PDT

I am using node exporter with kubernetes and prometheus to moniter the number of current tcp connections

From this post i found node_sockstat_TCP_alloc or node_netstat_Tcp_CurrEstab.

I started doing tcp connection using mosquito connect and pub.

The tcp_aloc increased as the number of mqtt user increase

enter image description here

But node_netstat_Tcp_CurrEstab is always constant

enter image description here

Is it required to set resourceKey on the request to access files through Google Drive API service

Posted: 17 Aug 2021 07:59 AM PDT

As per documentation https://developers.google.com/drive/api/v3/resource-keys, after 13 Sept 2021 security update, if your application is accessing Drive files, you need to update the code to set resourceKey on request in order to access files that have permission with type=domain or type=anyone, where withLink=true (v2) or allowFileDiscovery=false (v3).

Our application does not call Drive API directly (e.g. https://www.googleapis.com/drive/v3/files). Instead it uses Google Drive API service (v3-rev191-1.25.0) to access Drive files . So do we need to make code changes to set resourceKey on the request? or we just need to update version of Google Drive API service and that service will internally take care of setting resource key?

Is there a way to aggregate multiple Pandas rows into a single row with extra columns?

Posted: 17 Aug 2021 08:00 AM PDT

I'm looking for an efficient way to aggregate a Pandas DataFrame based on a column value, where the columns are expanded and named based on the value in another column. This is best explained by an example:

This is my input DataFrame:

  customer device   x   y   z  0     Jack      M   1   2   3  1     Jack      D   4   5   6  2     Jane      M   7   8   9  3     Jane      D  10  11  12  

And this is the output I want:

  customer  x_M  y_M  z_M  x_D  y_D  z_D  0     Jack    1    2    3    4    5    6  1     Jane    7    8    9   10   11   12  

As you can see, "aggregation" is possibly a misleading word to use. Rather, the rows are "expanded" into columns that are named based on another column from their respective rows.

In my mind I will have to do some sort of loop - but I was hoping for a more efficient Pandas operation than can do the same thing. Thanks.

How can you programmatically format content to paste into Google Spreadsheets?

Posted: 17 Aug 2021 08:00 AM PDT

Say you want to copy a CSV like this:

foo,1,"asdf"  bar,2,"fdsa"  baz,3,"helloworld"  

You copy it with CMD+C/CTRL+C, then go to Google Spreadsheets and press CMD+V/CTRL+V, and you end up with one cell containing all the content. Not what I was hoping for...

How can you format it using JavaScript and the clipboard so it pastes each row/cell into the proper place in the spreadsheet? I have this to do the copying to clipboard in JavaScript:

const textarea = document.createElement('textarea')  textarea.style.opacity = 0  textarea.style.width = 0  textarea.style.height = 0  textarea.style.position = 'absolute'  textarea.style.bottom = '-100%'  textarea.style.left = '-100%'  textarea.style.margin = 0  document.body.appendChild(textarea)    const copy = function(text){    textarea.value = text    textarea.select()    document.execCommand('copy')  }    document.addEventListener('click', () => {    copy(  `foo,1,"asdf"  bar,2,"fdsa"  baz,3,"helloworld"`    )  }  

How to format it so the Spreadsheet in Google Spreadsheets formats it as rows and columns properly?

how to make a scrollable div's height, dynamic?

Posted: 17 Aug 2021 08:00 AM PDT

I'm trying to build a section with defined height. in this section there is a sticky header (that its height may increase) and a body. what i want is to make the body scrollable. but because of header's dynamic height, i can't give it an exact height!! what should i do??

<div class="section">      <div class="header"></div>      <div class="body"></div>  </div>  
.section{      height: 100vh;      overflow: hidden;         position: relative;  }  .header{      position: sticky;      top: 0;      background: #fff;      z-index: 2;  }  .body{      // height: ???;      overflow-y: auto  }  

I can give the section overlfow-y: auto but it will show the scroll in whole section (even in header) but i only want the body be scrollable and the whole section height must be the window height (100vh)

Filling list according to rules

Posted: 17 Aug 2021 08:00 AM PDT

Sorry for the not-so-explicit title, my problem is very specific and I have no idea how to make it short.

Here's the thing: I have a list of exactly 8 elements that are -1, 0 or +1. I want to change the 0s in either -1 or +1. The thing is that sometime I can't know how to fill it; I just know that at the end, I must have no 0; exactly 5 times -1 and 3 times +1. The idea would be, that given a list containing some 0s, I end up with all the admissible lists (with good number of -1/+1) I can obtain by changing the values of the 0s. For instance, imagine the list is:

L  = [-1,-1,-1, 0, 0, 1, 1,-1]   

As L contains 4 times -1 and 2 times +1, I would like to explore what would happen with:

L1 = [-1,-1,-1, 1,-1, 1, 1,-1]   L2 = [-1,-1,-1,-1, 1, 1, 1,-1]   

I had an idea which is to do as follows: count how much 0 there are, count to two power that, convert it in binary, and fill accordingly; putting -1 instead of 0, and discarding the cases that have not the good ration of +1/-1. That seems kind of overkill to me, and I'm pretty sure there is a smarter way to do it.

Your thoughts?

Output table after using pickerInput is not showing as it should using ShinyDashboard

Posted: 17 Aug 2021 08:00 AM PDT

I am creating an app in ShinyDashboard and I am using pickerInput in order to have the possibility to select which columns do I want to use.

When I am selecting all the columns (or at least, more than 2) the output table looks well.

image 1

However, If I select only two columns the columns are displaced. It looks like this:

image 2

Do you know what it is going on? Do you know how to solve it?

Here you have the code:

library(shiny)  library(shinydashboard)  library(magrittr)  library(DT)  library(shinyWidgets)  library(dplyr)    ui <- dashboardPage(        dashboardHeader(title = "Basic dashboard"),    ## Sidebar content    dashboardSidebar(      sidebarMenu(        menuItem("Table", tabName = "Table", icon = icon("th"))      )    ),        dashboardBody(      fluidRow(      tabItems(                tabItem(tabName = "Table",                sidebarPanel(                                    uiOutput("picker"),                                    checkboxInput("play", strong("I want to play with my data"), value = FALSE),                                    conditionalPanel(                    condition = "input.play == 1",                    checkboxInput("change_log2", "Log2 transformation", value = FALSE),                    checkboxInput("run_sqrt", "sqrt option", value = FALSE)),                                    actionButton("view", "View Selection")                                  ),                                # Show a plot of the generated distribution                mainPanel(                  dataTableOutput("table")                                  )        )      )    )    )  )    server <- function(input, output, session) {        data <- reactive({      mtcars    })        data1 <- reactive({            dat <- data()            if(input$change_log2){        dat <- log2(dat)      }            if(input$run_sqrt){        dat <- sqrt(dat)      }            dat    })        # This is going to select the columns of the table    output$picker <- renderUI({      pickerInput(inputId = 'pick',                  label = 'Select columns to display',                  choices = colnames(data()),                  options = list(`actions-box` = TRUE),multiple = T,                  selected = colnames(data()))    })        #This function will save the "new" table with the selected columns.    selected_columns <- eventReactive(input$view,{      selected_columns <- data1() %>%        select(input$pick)      return(selected_columns)          })        output$table <- renderDataTable({            datatable(        selected_columns(),        filter = list(position = 'top', clear = FALSE),        selection = "none",        rownames = FALSE,        extensions = 'Buttons',                options = list(          scrollX = TRUE,          autoWidth = TRUE,          dom = 'Blrtip',          buttons =            list('copy', 'print', list(              extend = 'collection',              buttons = list(                list(extend = 'csv', filename = "Counts", title = NULL),                list(extend = 'excel', filename = "Counts", title = NULL)),              text = 'Download'            )),          lengthMenu = list(c(10, 30, 50, -1),                            c('10', '30', '50', 'All'))        ),        class = "display"      )                },rownames=FALSE)      }    shinyApp(ui, server)  

Thanks very much in advance,

Regards

Is there a way to print integers normally that are assigned to a pointer array?

Posted: 17 Aug 2021 08:00 AM PDT

I am creating a program that involves pointers and arrays and I have stumbled upon a problem. Basically, I created three integers that would get its value from the user's input and later declared them all in an array in order to change all of their values in one single loop.

Then I declared a pointer which uses the array inside a loop in order to do that.

Expecting the pointer-array in the loop to print out the data in a normal order, rather, it had printed it backwards.

Mind you, I am a huge beginner to programming C++ and is still learning about pointers.

I have tried changing the index number in

pntr = &salary[3];  

but 3 is the only one that prints out every input in the loop. 0 doesn't do the trick, same goes to 1, 2, 4 and so on and so forth.

I would like to have the new output to have the same syntax (salary1, salary2, salary3) and not reverse it (salary3, salary2, salary1) to have the inputted values be printed out.

Here is the code:

#include <iostream>  using namespace std;   int main() {  int salary1, salary2, salary3;    cout << "Enter salary for John: ";  cin >> salary1;  cout << "Enter salary for Mark: ";  cin >> salary2;  cout << "Enter salary for Nathan: ";  cin >> salary3;  cout << "Name \t Age \t Position \t Salary" << endl;  cout << "John \t 16 \t Engineer \t " << salary1 << endl;  cout << "Mark \t 16 \t Scouter \t " << salary2 << endl;  cout << "Nathan \t 17 \t Manager \t " << salary3 << endl;    int salary[3] = {salary1, salary2, salary3};  int *pntr;    pntr = &salary[3];    for(int x = 0; x < 3; x++) {  cout << "Enter new salary: " << endl;  cin >> *(pntr + x);  cout << "Salary 1:" << salary1 << endl;  cout << "Salary 2:" << salary2 << endl;  cout << "Salary 3:" << salary3 << endl;  }    cout << "Name \t Age \t Position \t Salary" << endl;  cout << "John \t 16 \t Engineer \t " << salary1 << endl;  cout << "Mark \t 16 \t Scouter \t " << salary2 << endl;  cout << "Nathan \t 17 \t Manager \t " << salary3 << endl;      return 0;  

}

Thank you!

Granting access to other class views upon successful authentication Django REST

Posted: 17 Aug 2021 08:00 AM PDT

Here is my API in Django REST.

Here is my code:

from rest_framework.permissions import IsAuthenticated, AllowAny    class CreateItems(generics.CreateAPIView):      permission_classes = [IsAuthenticated]            queryset = SomeModel.objects.all()      serializer_class = SomeSerializer                  class AuthStatus(APIView):        permission_classes = [AllowAny]        def post(self, request, *args, **kwargs):                              token = self.request.data['itemsReturnedAuthAPI']['accessToken']          if(token):              return Response({"Token":token})            else:              return Response({"message":"No Token Found!"})            

I have an authentication microservice that I get the JWT Token from for the user in order to have access to the views. In the AuthStatus class I am checking the token.

My Question: I want to grant the user access to the CreateItems class, after the token is provided

awk to get last working day in all month of a year

Posted: 17 Aug 2021 08:00 AM PDT

I'm converting a sql logic of finding the last working day in each month of a given year using awk. Here is my code which looks correct but runs infinitely,

awk -v year=2020 ' function dtp(_dt) { return strftime("%F", mktime(_dt " 0 0 0")) }  function dtday(_dt) { return strftime("%a", mktime(_dt " 0 0 0")) }   function dtmon(_dt) { return strftime("%b", mktime(_dt " 0 0 0")) }    BEGIN   { ldy=strftime("%j",mktime(year " 12 31 0 0 0" ))      for(i=1;i<=ldy+0;i++)      {        df=year " "  1  "  " i         if(dtday(df) != "Sun" && dtday(df) != "Sat" )        a[dtmon(df)]=dtp(df) "|" dtday(df)      }         }    END {  for(i in a) print i,a[i] }    '  

I think I landed up in convoluted way of doing it. Can this be fixed or any other simpler awk solution possible?. I'm looking for an output like below.

Fri 2020-01-31 :: 2020-01-31  Sat 2020-02-29 :: 2020-02-28 # 29 is sat, so 28  Tue 2020-03-31 :: 2020-03-31  Thu 2020-04-30 :: 2020-04-30  Sun 2020-05-31 :: 2020-05-29 # 31 is Sun, so 29  Tue 2020-06-30 :: 2020-06-30  Fri 2020-07-31 :: 2020-07-31  Mon 2020-08-31 :: 2020-08-31  Wed 2020-09-30 :: 2020-09-30  Sat 2020-10-31 :: 2020-10-30 # 31 is Sat, so 30th  Mon 2020-11-30 :: 2020-11-30  Thu 2020-12-31 :: 2020-12-31  

Refer to child class foreign key in base abstract model

Posted: 17 Aug 2021 08:00 AM PDT

I am trying to access the child model foreign key in base abstract model so I don't have to repeat the foreign key in each of the child model.

Here is my code:

class BaseModel(models.Model):      child_field = models.ForeignKey(to='child_class_either_ModelA_OR_ModelB')        class Meta:          abstract = True      class ModelA(BaseModel):      ....    class ModelB(BaseModel):      ....  

I want to refer the child model in base abstract model.

Is there a way to use an child model in base model?

docker-compose - shared network between multiple projects

Posted: 17 Aug 2021 08:00 AM PDT

I want to share a network between multiple docker-compose projects:

assume the first project has a web server (nginx):

#projet1/docker-compose.yml  services:    nginx:      image: nginx:stable      networks:        - shared  networks:    shared:  

I want to use the shared network to connect nginx with apps in project2 and project3

project2:

#projet2/docker-compose.yml  services:    app1:      image: php-fpm    networks:      - shared  networks:    shared: # this network must point to project1>networks>shared  

project3:

#projet3/docker-compose.yml  services:    app2:      image: php-fpm      networks:        - shared  networks:    shared: # this network must point to project1>networks>shared  

I know that I can do it by using an external network but this method requires a ready network that was created before running projects.

How can i stop localstorage from overwriting itself?

Posted: 17 Aug 2021 08:00 AM PDT

I have this code:

//check if local storage contains color on component mount  useEffect(() => {    const lS = window.localStorage.getItem("color");    if (lS) return setColor(lS);    localStorage.setItem("color", "");  }, []);      //update color on click  const handleClick = e => {    const lS = window.localStorage.getItem("color");    if (lS === "") {      localStorage.setItem("color", "red");      setColor("red");    }    if (lS !== "") {      localStorage.setItem("color", "");      setColor("");    }  };  
 <div onClick={handleClick} className="icon__content--container">      <Icon        style={{ color: color }}      />    </div>  

I want to use this code on multiple icons. But what happens is that every icon is tied to same localStorage object so it overwrites the values for different icons. How can i change this code so that it does not overwrite.

Host Blazor WebAssembly with Authentication project on windows IIS

Posted: 17 Aug 2021 08:00 AM PDT

I just created Blazor WebAssembly with Authentication project and didn't change anything on the code then tried to host the project on windows IIS it always gives me this error when the website run:

("crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]        Unhandled exception rendering component: Could not load settings from '_configuration/MyWebstieAut.Client'        Error: Could not load settings from '_configuration/MyWebstieAut.Client'           at a.createUserManager (http://mywebsiteaut.com/_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js:1:5887)           at Generator.prototype.next (native code)  Microsoft.JSInterop.JSException: Could not load settings from '_configuration/MyWebstieAut.Client'  Error: Could not load settings from '_configuration/MyWebstieAut.Client'     at a.createUserManager (http://mywebsiteaut.com/_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js:1:5887)     at Generator.prototype.next (native code)    at System.Threading.Tasks.ValueTask`1[TResult].get_Result () <0x21bcc70 + 0x0002c> in <filename unknown>:0     at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsyn")  

Can you help me in this?

Thanks

program.cs:

 var builder = WebAssemblyHostBuilder.CreateDefault(args);              builder.RootComponents.Add<App>("#app");              builder.Services.AddHttpClient("{ProjectName}.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))                  .AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();                // Supply HttpClient instances that include access tokens when making requests to the server project              builder.Services.AddScoped(sp => sp.GetRequiredService<IHttpClientFactory>().CreateClient("{ProjectName}.ServerAPI"));              builder.Services.AddApiAuthorization();                await builder.Build().RunAsync();  

appsettings.json:

{    "ConnectionStrings": {      "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-{ProjectName}.Server-A5A9DCDA-10E3-45AE-A34F-DEF0D6A04784;Trusted_Connection=True;MultipleActiveResultSets=true",      "{ProjectName}ServerContextConnection": "Server=(localdb)\\mssqllocaldb;Database={ProjectName}.Server;Trusted_Connection=True;MultipleActiveResultSets=true"    },    "Logging": {      "LogLevel": {        "Default": "Information",        "Microsoft": "Warning",        "Microsoft.Hosting.Lifetime": "Information"      }    },    "IdentityServer": {      "Clients": {        "{ProjectName}.Client": {          "Profile": "IdentityServerSPA"        }      }    },    "AllowedHosts": "*"  }  

How to copy such a set of characters on a pop-up page to a clipboard using applescript or javascript (chrome)?

Posted: 17 Aug 2021 07:59 AM PDT

How to copy such a set of characters on a pop-up page to a clipboard using applescript or javascript (chrome)?

Pic. Screen of symbols and code from the inspector

Double-clicking does not always copy all 8 sets of 4 characters.

There is no name, tag or ID in the code.

Maybe it's possible to find text kind of that?

xxxx xxxx xxxx xxxx

xxxx xxxx xxxx xxxx

KNVC XFFZ XUVM P46U ZSK6 TOZR OQH3 HYXZ

How would you solve this problem?

This is code:

<div class="_59s7 _9l2g" role="dialog" aria-label="Содержание диалога" style="width: 525px; margin-top: 58px;"><div class="_4t2a"><div><div><div><div class="_61mx"><div class="_1py_ _1rb6" style="background-color: rgb(255, 255, 255); box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 0px 1px, rgba(0, 0, 0, 0.15) 0px 16px 32px 2px; height: inherit; border-radius: 4px;"><span class="layerCancel _2ph_ _6ued" style="height: 16px; width: 16px; z-index: 2;"><button class="_42d_ _32qq _3n5r layerCancel" type="button" style="height: 16px; width: 16px;" tabindex="0"><span class="accessible_elem">Закрыть</span><span aria-hidden="true" class="_3n5s" style="margin-left: -8px; margin-top: -8px;"><i size="16" alt="" data-visualcompletion="css-img" class="img sp_O94X-RuXZcj_2x sx_9f0088"></i></span></button></span><div class="_3lxv" style="background-color: rgb(255, 255, 255); border-bottom: 1px solid rgb(218, 221, 225); padding: 12px 44px 12px 16px;"><div class="_3qn7 _61-3 _2fyi _3qng"><div class="_3lxw"><div class="_3qn7 _61-0 _2fyi _3qng"><div aria-level="1" class="ellipsis" data-hover="tooltip" data-tooltip-display="overflow" id="js_3p" role="heading" style="letter-spacing: normal; font-family: -apple-system, system-ui, BlinkMacSystemFont, Arial, sans-serif; color: rgb(28, 30, 33); font-size: 16px; font-weight: bold; line-height: 20px;">Двухфакторная аутентификация</div></div><div></div></div></div></div><div class="_jmh" style="letter-spacing: normal; font-family: -apple-system, system-ui, BlinkMacSystemFont, Arial, sans-serif; color: rgb(28, 30, 33); font-size: 12px; line-height: 16px;"><div class="_2xaj"><div><div><div class="_4m05"><div class="_4m09"><img src="/images/settings/security/two_fac/setup/ICON_Method_Generator.png" height="56" width="56" alt="" class="img"></div><div class="_4m0a"><div role="heading" aria-level="3" style="font-family: -apple-system, system-ui, BlinkMacSystemFont, Arial, sans-serif; font-size: 16px; line-height: 20px; letter-spacing: normal; font-weight: bold; overflow-wrap: normal; text-align: left; color: rgb(28, 30, 33);"><div>Настройка с помощью стороннего аутентификатора</div></div><div class="_3-8x" style="font-family: -apple-system, system-ui, BlinkMacSystemFont, Arial, sans-serif; font-size: 14px; line-height: 18px; letter-spacing: normal; overflow-wrap: normal; text-align: left; color: rgb(96, 103, 112);"><div>Отсканируйте этот QR-код с помощью приложения для аутентификации (например, DUO или Google Authenticator).</div></div></div></div></div><div class="_1-nv"><div class="_1-ns"><img src="https://www.facebook.com/qr/show/code/?margin=1&amp;pixel_size=5&amp;data=otpauth%3A%2F%2Ftotp%2FID%3A100071349439905%3Fsecret%3DKNVCXFFZXUVMP46UZSK6TOZROQH3HYXZ%26digits%3D6%26issuer%3DFacebook&amp;hash=AQBmw6Dww2w-7LQ17ZQ" alt="" class="img"></div><div class="_1-nt"><span class="_3-97" style="font-family: -apple-system, system-ui, BlinkMacSystemFont, Arial, sans-serif; font-size: 12px; line-height: 16px; letter-spacing: normal; overflow-wrap: normal; text-align: center; color: rgb(96, 103, 112); display: inline-block;"><div>Или введите этот код в приложении для аутентификации</div></span><span style="font-family: -apple-system, system-ui, BlinkMacSystemFont, Arial, sans-serif; font-size: 14px; line-height: 18px; letter-spacing: normal; font-weight: bold; overflow-wrap: normal; text-align: center; color: rgb(28, 30, 33);">KNVC XFFZ XUVM P46U ZSK6 TOZR OQH3 HYXZ</span></div></div></div></div></div><div class="_4iyh _2pia _2pi4" style="border-top: 1px solid rgb(218, 221, 225);"><span class="ellipsis"></span><span class="_4iyi"><div style="display: inline-block;"><div style="margin-right: 8px; display: inline-block;"><button type="button" aria-disabled="false" class="_271k _271m _1qjd layerCancel _7tvm _7tv2 _7tv4" style="letter-spacing: normal; color: rgb(68, 73, 80); font-size: 12px; font-weight: bold; font-family: -apple-system, system-ui, BlinkMacSystemFont, Arial, sans-serif; line-height: 26px; text-align: center; background-color: rgb(245, 246, 247); border-color: rgb(218, 221, 225); height: 28px; padding-left: 11px; padding-right: 11px; border-radius: 2px;"><div class="_43rl"><div data-hover="tooltip" data-tooltip-display="overflow" class="_43rm">Отмена</div></div></button></div><div style="display: inline-block;"><button rel="post" type="button" aria-disabled="false" class="_271k _271m _1qjd _7tvm _7tv2 _7tv4" style="letter-spacing: normal; color: rgb(255, 255, 255); font-size: 12px; font-weight: bold; font-family: -apple-system, system-ui, BlinkMacSystemFont, Arial, sans-serif; line-height: 26px; text-align: center; background-color: rgb(24, 119, 242); border-color: rgb(24, 119, 242); height: 28px; padding-left: 11px; padding-right: 11px; border-radius: 2px;"><div class="_43rl"><div data-hover="tooltip" data-tooltip-display="overflow" class="_43rm">Продолжить</div></div></button></div></div></span></div></div></div></div></div></div></div></div>  

What is the difference between BBWebview and GDWebview?

Posted: 17 Aug 2021 08:00 AM PDT

GDWebview has been in the SDK for a while. BBWebview is newly referenced in SDK 9.2. They seem to both extend from android.webkit.Webview Is there a difference between these classes? Are there use cases that each are intended for?

How I can run CMD commands as administrator with powershell?

Posted: 17 Aug 2021 08:00 AM PDT

I want to run CMD commands as admin with Powershell. There is full command list:

Dism /OnLine /CleanUp-Image /CheckHealth&Dism /OnLine /CleanUp-Image /RestoreHealth  

Can be any way to do this? I want to do with Run command.

Postman - Upload file and other argument with GraphQL

Posted: 17 Aug 2021 08:00 AM PDT

I am trying to use Postman to upload a file to GraphQL.

I know how I can upload a file, however, in my mutation I have to pass a String! together with the Upload!.

I am not sure where I can pass this String! in Postman.

My mutation:

mutation AddBookImageOne($bookId: string, $bookImageOne: Upload!){    addBookImageOne(bookId: $bookId, bookImageOne: $bookImageOne)  }  

I tried to pass bookId in the variables key but I keep getting the error:

"message": "Variable "$bookId" of required type "String!" was not provided.",

I checked this: Graphql mutation to upload file with other fields but they use CURL

"Operations" in postman field is:

{"query":"mutation AddBookImageOne($bookId: String!, $bookImageOne: Upload!){\n  addBookImageOne(bookId: $bookId, bookImageOne: $bookImageOne)\n}"}  

enter image description here

UPDATE error. SQLSTATE[HY093]: Invalid parameter number

Posted: 17 Aug 2021 08:00 AM PDT

require_once '../app/config.php';    if (!empty($_POST['update'])) {     $sql = "UPDATE web_usr SET                  email = :email,                  fname = :fname,                  lname = :lname,                  web_usr = :web_usr,                 usr_note = :usr_note,                  avatar = :avatar,                  usr_skill = :usr_skill                  WHERE id = :id";       $stmt = $conn->prepare($sql);     $stmt->bindParam(':email', $email, PDO::PARAM_STR);   $stmt->bindParam(':fname', $fname, PDO::PARAM_STR);   $stmt->bindParam(':lname', $lname, PDO::PARAM_STR);   $stmt->bindParam(':web_usr', $web_usr, PDO::PARAM_STR);   $stmt->bindParam(':usr_note', $usr_note, PDO::PARAM_STR);   $stmt->bindParam(':avatar', $avatar, PDO::PARAM_STR);   $stmt->bindParam(':usr_skill', $usr_skill, PDO::PARAM_STR);     //Execute the statement and insert the new account.   $result = $stmt->execute();     //If the signup process is succesful.   if($result) {     echo "Succesed";   } else {     echo "gagal";   }  }  

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number' in C:\xampp\htdocs\otakutangerang_admin\c_action.php:33 Stack trace: #0 C:\xampp\htdocs\otakutangerang_admin\c_action.php(33): PDOStatement->execute() #1 {main} thrown in C:\xampp\htdocs\otakutangerang_admin\c_action.php on line 33

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error' .. C:\xampp\..PDOStatement->fetch().. on line 83

Posted: 17 Aug 2021 08:00 AM PDT

I have actually seen similar questions on this "Fatal error: Uncaught exception 'PDOException'".

But I have not been able to use have I have seen to resolve the challenge am having.

Below are the code and the error message

<?php   $sql5 = " set @rownum := 0;   set @sum := 0;    select DISTINCT(ROUND(the_avg,4))   FROM (      select water_level,   @rownum := (@rownum + 1) as rownum,   @sum := IF(@rownum mod 7 = 1,0 + water_level,@sum + water_level) as running_sum,  IF(@rownum mod 7 = 0,@sum / 7,NULL) as the_avg  FROM " .$table." WHERE record_month_year = '".$startDateReport."'  order by id ASC  ) s ";  $result5 = $db->prepare($sql5);  $result5->execute();  while ($rowReport = $result5->fetch(PDO::FETCH_ASSOC)) {      ?>      <tr style="font-size:11px;">          <td><?php echo $rowReport['the_avg'] ; ?></td>          </tr>          <?php           }          ?>  

The line 83 is :

while ($rowReport = $result5->fetch(PDO::FETCH_ASSOC)) {  

error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error' in C:\xampp\htdocs\awos\includes\loadboreholedatareport.php:83 Stack trace: #0 C:\xampp\htdocs\awos\includes\loadboreholedatareport.php(83): PDOStatement->fetch() #1 C:\xampp\htdocs\awos\borData-report.php(46): include('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\awos\includes\loadboreholedatareport.php on line 83.

Printing HashMap In Java

Posted: 17 Aug 2021 08:00 AM PDT

I have a HashMap:

private HashMap<TypeKey, TypeValue> example = new HashMap<TypeKey, TypeValue>();  

Now I would like to run through all the values and print them.

I wrote this:

for (TypeValue name : this.example.keySet()) {      System.out.println(name);  }  

It doesn't seem to work.

What is the problem?

EDIT: Another question: Is this collection zero based? I mean if it has 1 key and value will the size be 0 or 1?

Set allow_url_include on SINGLE file

Posted: 17 Aug 2021 08:00 AM PDT

I've created a php file called pagebase.php that I'm quite proud of. It contains a class that created the whole html file for me from input such as css links and js links. In any case, this file is several hundred lines long, as it includes several helper functions such as cleanHTML() that removes all whitespace from the html code then, in layman's terms, makes the source look pritty.

I have decided to use this pagebase in all my projects, particularly in all my internal projects. I also plan to add and expand to the pagebase file quite a lot. So what I'm wondering is if it's possible to set the allow_url_include option to on, but just on this one single file.

If I got my theory right, that would allow me to include() that file from any server and get the pagebase class.

Thanks for all answers!

No comments:

Post a Comment