Saturday, October 30, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


What is the regular expresion for all capital letters and all non alphabetic characters

Posted: 30 Oct 2021 07:08 AM PDT

I need the regex for all non alphabetic character and capital letters only.

let str = "ThisIs-an_example";  

What regex should I use for separating the words correctly using arr.join so that it is "this is an example"

Calculate the maximum distance with given set of segments, that forms sticked triangles

Posted: 30 Oct 2021 07:08 AM PDT

I have spent significant amount of time to figure out how to create algorithm for this problem. So basically, we can calculate the height of triangle with given 3 segments. But what if two or more segments are added? It is going to form a new triangle stick to the other. But I could not calculate the height. Thanks for any help.

Handle select multiple on django

Posted: 30 Oct 2021 07:08 AM PDT

I have this on template

<select name="document" id="document" multiple="">          <option value="2">test 1</option>          <option value="3">test 2</option>  </select>  

When I select two options when I accept the request in views.py I got correctly 2 options selected

self.request.POST // It prints 'document': ['2', '3']  

But when I try to select the field like this

self.request.POST['document'] // It prints only '3'  

How can I select 2 options?

Thanks

Bash - Output of the text in console little by little

Posted: 30 Oct 2021 07:08 AM PDT

Is there a way to make the text display bit by bit in bash?

In Python it is something like this

import os, sys, time    def mkdir (z):      for e in z +'\n':          sys.stdout.write(e)          sys.stdout.flush()          time.sleep(00000.1)    mkdir('\033[1;91m[+]\033[1;92mHello world...\033[1;97m')  

Failed to start clash-s.service: Unit clash-s.service not found

Posted: 30 Oct 2021 07:07 AM PDT

The problem I have encountered

I'm fresh in using linux and today I encounted a strange problem.

I write the unit file as the photo posted above, and when I going to run command

sudo systemctl daemon-reload  sudo systemctl start clash-s  

and the error is always like Failed to start clash-s.service: Unit clash-s.service not found. I have tried to use chmod +x clash-s.service and rename it, but all in vain.

I also write a test unit file(copying from the clash-s.service), and it works properly. So I am really confused about the problem.

Is it possible to limit the amount of variations a user can do with woocommerce

Posted: 30 Oct 2021 07:07 AM PDT

A lot of the Q&A I'm finding online is about increasing the amount of variations you can make on a woocommerce variable product but I'm trying to limit the amount to 30. The reason being on some client sites I have done, they have like over 1000 variations which makes the product take an age to load. I'm creating a multivendor site so I'm trying to prevent problematic products from the get go. Some of the functions I have tried are:

add_filter( 'woocommerce_ajax_variation_threshold', 'ww_ajax_variation_threshold', 10, 2 );    function ww_ajax_variation_threshold( $default, $product ) {      return 30;  }  

and also

function wpse_rest_batch_items_limit( $limit ) {      $limit = 30;        return $limit;  }  add_filter( 'woocommerce_rest_batch_items_limit', 'wpse_rest_batch_items_limit' );  

These don't seem to work for me unfortunately. I also want to try and replicate this in the variation popup message. (see below)

enter image description here

Does anyone know if something like this is possible?

mongodb How to find restaurants with grades above 12

Posted: 30 Oct 2021 07:07 AM PDT

[mongodb How to find restaurants with grades above 12 ][1] [1]: https://i.stack.imgur.com/BqA7x.png

mongodb How to find restaurants with grades above 12

Toggle div content after a radio button is checked using CSS only

Posted: 30 Oct 2021 07:07 AM PDT

It is work when the radio buttons are same div level with "content1" and "content2",
How to make it work, if I put radio button to another div that outside the div "second"

suppose that the toggle1 is checked then content1 will show up

(using CSS and HTML ONLY, no javascript)

<!DOCTYPE html>  <html>  <head>  <style>  .content1  {      display:none;  }    .content2  {      display:none;  }    .toggle1:checked ~ .grid-container .content1  {    display: block;  }    .toggle2:checked ~ .grid-container .content2  {    display: block;  }  </style>  </head>  <body>  <div class="level1">    <div class="level2">      <input type=radio id="toggle1" name="toggle" class="toggle1">      <label for="toggle1">toggle1</label>      <input type=radio id="toggle2" name="toggle" class="toggle2">      <label for="toggle2">toggle2</label>    <div>  <div>    <div class="second">    <div class="tab content1">Content1</div>    <div class="tab content2">Content2</div>   </div>      </body>  </html>      

How to configure Google Authentication using IdentityServer4 avoiding external authentication error?

Posted: 30 Oct 2021 07:07 AM PDT

I am trying to configure Google authentication for my app using IdentityServer4. Here's my configuration code:

    private static IServiceCollection AddGoogleAuthProviderServices(          this IServiceCollection services,          IConfiguration configuration)      {          var googleExternalAuthProviderSettings = configuration              .GetSection(nameof(GoogleProviderSettings))              .Get<GoogleProviderSettings>();            services              .AddAuthentication()              .AddGoogle(options =>              {                  options.ClientId = googleExternalAuthProviderSettings.ClientId;                  options.ClientSecret = googleExternalAuthProviderSettings.ClientSecret;                  options.SignInScheme = googleExternalAuthProviderSettings.SignInScheme;                  options.CorrelationCookie.SameSite = SameSiteMode.Unspecified;              });            return services;      }        private static IServiceCollection AddIdentityServerServices(          this IServiceCollection services,          IConfiguration configuration)      {          var clients = configuration              .GetSection(ClientsSectionKey)              .Get<IEnumerable<ClientSettings>>()              .Select(settings => new Client              {                  ClientId = settings.ClientId,                  ClientName = settings.ClientName,                  RequireClientSecret = settings.RequireClientSecret,                  AllowedGrantTypes = settings.AllowedGrantTypes,                  RedirectUris = settings.RedirectUris,                  PostLogoutRedirectUris = settings.PostLogoutRedirectUris,                  AllowedCorsOrigins = settings.AllowedCorsOrigins,                  AllowedScopes = settings.AllowedScopes,                  EnableLocalLogin = false,              });            var apiScopes = configuration              .GetSection(ApiScopesSectionKey)              .Get<IEnumerable<ApiScopeSettings>>()              .Select(settings => new ApiScope              {                  Name = settings.Name,                  DisplayName = settings.DisplayName,              });            services              .AddIdentityServer()              .AddInMemoryClients(clients)              .AddInMemoryApiScopes(apiScopes)              .AddDeveloperSigningCredential();            return services;      }    

The appsettings:

{    "GoogleProviderSettings": {      "ClientId": "xxx",      "ClientSecret": "yyy",      "SignInScheme": "idsrv.external"    },    "ApiScopes": [      {        "Name": "Exchange",        "DisplayName": "Exchange"      }    ],    "Clients": [      {        "ClientId": "xxx",        "ClientName": "front",        "RequireClientSecret": false,        "AllowedGrantTypes": [          "authorization_code"        ],        "RedirectUris": [          "http://localhost:8080"        ],        "PostLogoutRedirectUris": [          "http://localhost:8080"        ],        "AllowedCorsOrigins": [          "http://localhost:8080",          "http://localhost:5105"        ],        "AllowedScopes": [          "Exchange"        ]      }    ]  }  

Here's my configuration in google developer console: enter image description here

localhost:5003 is my IdentityServer4 service address and the localhost:8080 is the place where the frontend application besides. While trying to authenticate from the frontend app im being redirected to google. Then when i sign in im getting an error from ExternalController.Callback function.

System.Exception: External authentication error     at IdentityServerHost.Quickstart.UI.ExternalController.Callback() in C:\Projekty\rtail\src\backend\IdentityService\Quickstart\Account\ExternalController.cs:line 87     at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)     at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)     at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)     at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)     at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)     at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()  --- End of stack trace from previous location ---     at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)     at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)     at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)     at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()  --- End of stack trace from previous location ---     at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)     at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)     at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)     at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events, IBackChannelLogoutService backChannelLogoutService)     at IdentityServer4.Hosting.MutualTlsEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes)     at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)     at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context)     at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)  

What am i doing wrong? Thanks for any help.

I would like to divide it into command, key, and value through input split and enter it in the dictionary

Posted: 30 Oct 2021 07:07 AM PDT

database = {}    while True:      print("Pleas type like Command,textA,textB")        Command, textA, textB = input().split(',')        if Command == 'PUT': // ex: PUT,a,c  PUT is command to a is key, c is value          database[textA] = textB          print("Success!")      elif Command == 'GET': // ex: GET,a GET is command to get a's value          if "textA" in database:              print(database.get('textA'))          else:              print("Not exist!")      elif Command == 'DELETE': // ex: DELETE,a DELETE is command to delete a's key&value          if "textA" in database:              del database['textA']              print("Success!")          else:              print("Not exist!")      elif Command == 'LIST':          if "textA" in database:              for KEY, VALUE in database.items():                  print(KEY, VALUE)          else:              print("Not exist!")  

I would like to receive a command and key value in the dictionary and operate the if statement according to each command. However, if statement works only when three values are received unconditionally, so GET, DELETE, and LIST cannot be used. I'm trying to use TRY and EXCEPT, but I don't understand well. Also, if you enter textA and textB exactly like that, I wonder if Key and Value will continue to be stored in the Dictionary Database. There are many restrictions because the input format is Command, textA, and textB unconditionally. I think I have to organize it with a repeat sentence, but I wonder if there is another way.

Does Drivers API work for Uber Eats delivery drivers too or just for passenger drivers?

Posted: 30 Oct 2021 07:07 AM PDT

I'd like to know if it's possible to recover information about Uber Eats deliverymen. I don't found information about that in the docs, I don't know if deliveryman is considered drivers too.

Oracle pass today's value to a variable and use it

Posted: 30 Oct 2021 07:08 AM PDT

I want to use today as a variable and use it in a query like this:

  select record_date,            another_column      from table     where record_date = v_today  order by record_date;  

Where v_today is the desired variable. How can I do it?

Python, Windows, Printing Large amounts of data to the terminal effectively

Posted: 30 Oct 2021 07:08 AM PDT

TL;DR looking for a way to speed up printing to terminal

i am currently working on a project that basically lets you print out images in the terminal using ANSI escape codes, (requires zooming out for best results so i recommend using the new windows terminal)

This is the code:

try:      from PIL import Image  except:      from Lib.PIL import Image  from time import time  from os import system  from sys import argv, stdout  from pathlib import Path      def imgToTxt(path: Path, x_ratio: int, y_ratio: int, pixel: str, do_bg: bool, stat: bool, do_prnt: bool, do_warp: bool):      # COLOR FUNCTIONS      fg = lambda c: f"\x1b[38;2;{str(c[0])};{str(c[1])};{str(c[2])}m"      bg = lambda c: f"\x1b[48;2;{str(c[0])};{str(c[1])};{str(c[2])}m"      # /COLOR FUNCTIONS        st = time()      prnt_pixels = list()      _c = False        # IMAGE DATA      im = Image.open(path)      pixels = im.load()      width, height = im.size      # / IMAGE DATA        if stat:          print(height, y_ratio)          print(width, x_ratio)        system("")      # GENERATION LOOP      for y in range(0, height, y_ratio):          if do_warp:              if _c:                  _c = False; continue              else:                  _c = True          for x in range(0, width, x_ratio):                pu = pixels[x, y]              pl = pixels[x, y + 1 if y + 1 < height else y]                p = fg(pu) + ((bg(pl) if do_warp else bg(pu)) if do_bg else "") + pixel + "\x1b[0m"              prnt_pixels.append(p)            else:              prnt_pixels.append("\n")      # /GENERATION LOOP        # PRINTING      if do_prnt:          for p in prnt_pixels:              stdout.write(p)      # /PRINTING        nd = time()      print(("time to generate", nd - st) if stat else "")      return prnt_pixels      if __name__ == '__main__':      argv.append("-run")      argv.append("True")      if "help" in argv[1]:          print(              """ Convert an image into text                    \r    line commands:                    \r        -path [PATH]    -- [PATH] full path to the image                    \r        -xr [INT]       -- [INT] number between 1 and size of image, determines the x ratio (1 being raw)                    \r        -yr [INT]       -- [INT] number between 1 and size of image, determines the y ratio (1 being raw)                    \r        -pix [STR]      -- [STR] string of length 2, determines the pixel to use, default 'OO'                    \r        -do_bg [BOOL]   -- [BOOL] boolean, determines if the background has to be filled, default 'True'                    \r        -do_prnt [BOOL] -- [BOOL] boolean, determines if the image will be displayed, default 'True'                    \r        -do_warp [BOOL] -- [BOOL] boolean, determines if to warp the image in return for higher quality, default 'False', WARNING this option will force the change of default pixel                    \r        -help OR /help  -- Display this message""")        else:          # ALL          if len(argv) == 1:              argv = input(r'args \>').split(" ")          # /ALL            # SET TO NEXT VALUE          if "-path" in argv:              _ = argv.index("-path") + 1              path = Path(argv[_])          else:              path = r"C:\\Windows\\Cursors\\aero_unavail_xl.cur"            if "-xr" in argv:              _ = argv.index("-xr") + 1              x_ratio = int(argv[_])          else:              x_ratio = 1            if "-yr" in argv:              _ = argv.index("-yr") + 1              y_ratio = int(argv[_])          else:              y_ratio = 1            if "-pix" in argv:              _ = argv.index("-pix") + 1              pix = argv[_]          else:              pix = "00"            # /SET TO NEXT VALUE            # TRUE | FALSE          if "-do_bg" in argv:              _ = argv.index("-xr") + 1              match argv[_].lower():                  case 'true':                      do_bg = True                  case 'false':                      do_bg = False                  case _:                      raise Exception("-do_bg takes only true/false statements")          else:              do_bg = True            if "-do_warp" in argv:              _ = argv.index("-do_warp") + 1              match argv[_].lower():                  case 'true':                      do_warp = True                      pix = '▀'                  case 'false':                      do_warp = False                  case _:                      raise Exception("-do_warp takes only true/false statements")          else:              do_warp = False            if "-do_prnt" in argv:              _ = argv.index("-do_prnt") + 1              match argv[_].lower():                  case 'true':                      do_prnt = True                  case 'false':                      do_prnt = False                  case _:                      raise Exception("-do_prnt takes only true/false statements")          else:              do_prnt = True            if "-stat" in argv:              _ = argv.index("-stat") + 1              match argv[_].lower():                  case 'true':                      stat = True                  case 'false':                      stat = False                  case _:                      raise Exception("-stat takes only true/false statements")          else:              stat = True            if "-run" in argv:              _ = argv.index("-run") + 1              match argv[_].lower():                  case 'true':                      run = True                  case 'false':                      run = False                  case _:                      raise Exception("-run takes only true/false statements")          else:              run = False          # /TRUE | FALSE            if run:              imgToTxt(path=path, x_ratio=x_ratio, y_ratio=y_ratio, pixel=pix, do_bg=do_bg, do_prnt=do_prnt, do_warp=do_warp, stat=stat)  

the basic way it works is that it gets each pixel color data of an image and prepares a correct ANSI code for the color; ESC[38;2;{R};{G};{B}m
then in a later stage printing it

i have been looking into a way to speed up the printing process IE, using stdout, using a separate loop to generate the data and to print it, i even tried to use multiple threads (i know how stupid that sounds...), using alternative buffer, but in the end i got mostly fractions of a speed increase.

is there any way, even a crazy one, that would significantly speed up this process?

What is the real-time memory performance of modern server CPU's?

Posted: 30 Oct 2021 07:08 AM PDT

At time of writing, high-end CPUs support 8-channel DDR4 at 3200 speed. This gives a theoretical memory bandwidth of 204 GByte/s.

With "real-time memory performance" I mean that a device reads / writes a certain amount of data over PCIe and the requests are serviced in the microsecond range or better. The transfer should be able to run for minutes, without experiencing larger delays even once.

This is the background of my question:

My device writes about 12 GByte/sec over PCIe 3.0 x16. At the same time, the data is stored on a NVME drive array over PCIe 4.0 x16.

My current CPU is marketed to support 204 GB/s memory bandwidth. According to my (naive?) calculation, this bandwidth is used to (12+12)/204= 12 %. Therefore I expected it to run smoothly.

In reality, the DMA is sometimes delayed for up to 100 us. Not very often, but it happens several times a second.

The CPU cores aren't doing much, by the way. And I know for sure that the delay is not caused by interrupts and such. (My DMA engine runs without any software intervention.) Prioritizing this PCIe connection in BIOS didn't help.

  • Am I asking too much? Are these chips just not built for real-time performance?

  • Does DDR4 need some kind of periodic recalibration / housekeeping?

  • Are there CPUs available that can handle this traffic?

[Edit]

The write DMA itself is working fine, for several minutes. But as soon as I start accessing the disk at the same time (e.g. CrystalDiskMark) the write DMA starts to stutter.

Why is Flutter's key not default?

Posted: 30 Oct 2021 07:07 AM PDT

Other GUI frameworks such as MFC(Windows) and Qt Quick distinguish basic GUI elements by HANDLE or ID. I know that HANDLE and ID correspond to the Key concept in Flutter. I guess this has to do with some optimization. I'd like to know more precisely why the key value is not assigned by default to Flutter's widgets.

How to make sure the email is logged in only once?

Posted: 30 Oct 2021 07:07 AM PDT

I created a small chrome extension for a specific scope of users. How can I make sure that a user is logged in only on one machine to avoid sharing the Extension without users paying for it?

Is there any way to do so?

With other apps I check the UUID and compare it against my list of users.

I struggle to understand the identify API tbh.

This is my way currently but it only tracks if the user is in my list. It is inside my popup.JS file so it gets triggered when the users click on the extension icon.

Edit:

(function () {      chrome.identity.getProfileUserInfo({ 'accountStatus': 'ANY' }, async function (info) {          email = info.email;          console.log(info.id);            let response = await fetch('https://pastebin.com/');          let data = await response.text();            console.log(data.indexOf(info.id));            if (info.id === '') {              chrome.browserAction.setPopup({ popup: 'index.html' });              alert(info.id);          } else if (data.indexOf(info.id) !== -1) {              console.log('License is valid');          } else {              chrome.browserAction.setPopup({ popup: 'index.html' });              alert(info.id);                // block chrome extension usage;          }      });  })();  

Excel not returning the right value in using "IF" function

Posted: 30 Oct 2021 07:07 AM PDT

I am trying to see any of 3 values are not "#VALUE!" by applying this statement:

These values are in columns B,C and D. it works in most rows but not all.

=IF(B1>0,1,(IF(C1>0,1,(IF(D1>0,1,0)))))

You can see Row 14 is not working

enter image description here

Parametrize a function with a variable. Then delete the variable

Posted: 30 Oct 2021 07:07 AM PDT

I would like to make the following code run:

mu = 5  rnorm2 <- function(N) rnorm(N, mean = mu, sd = 1)  

And then be able to use the rnorm2 function regardless of the presence of the mu variable in the environment. In other words, set the value of the 'mean' argument with the "mu" value once and for all.

Is that possible ?

CLI upload main.js file size limited when building with react and threejs

Posted: 30 Oct 2021 07:08 AM PDT

Is there a way around the file size limitation. I am building a react module with three js (using the cms-react-boilerplate). The project builds fine but it cant uplaod the main.js file as it is 2.1MiB. it gives me the following error:

[ERROR] Error validating template. [ERROR] line 0: Coded files must be smaller than 1.5 MiB

I tried to upload the file directly to the design manager but was given the same error. I also tried to create a main.js file and past the code into it but was give the following error:

Error:Coded file buffer must be smaller than 2.0 MiB

Slow rollup.js bundling after copying in a 3rd-party library

Posted: 30 Oct 2021 07:07 AM PDT

I'm using https://shoelace.style (in my Svelte project), and following the example config in shoelace docs, I added a copy() plugin to my rollup.config.js, copying it to public/vendor/shoelace:

export default {    // SNIP    plugins: [      // SNIP      copy({        targets: [          {            src: path.resolve(              __dirname,              "node_modules/@shoelace-style/shoelace/dist/assets"            ),            dest: path.resolve(__dirname, "public/vendor/shoelace"),          },        ],      }),      // SNIP    ],  };    

It works, but now the build takes really really long - upwards of 40s, including incremental rebuilds on file change. I am fairly sure the time loss isn't because it's accidentally copied every time, as the asset folder is just 6M.

So, I suppose there's some tree-shaking and/or optimizations going on? Is there way to exclude the folder from rollup processing - or to troubleshoot/profile the bundling process anyhow?

(If necessary, I can also post the rest of the config; but it's otherwise standard new app template obtained by npx degit sveltejs/template and adding/removing the copy plugin made all the difference.)

Android 12: How to prevent activity restart on changing phone wallpaper?

Posted: 30 Oct 2021 07:07 AM PDT

On Android 12,

  1. If we open an activity

  2. Go to the home screen of the phone to change the wallpaper

  3. Switch back to our activity, the activity restarts.

It seems it is related to the Material You theming.

I would like to disable the restarting of activity when my app comes to the foreground. Is there a way?

What does this strange number mean in the output? Is this some memory Location? [duplicate]

Posted: 30 Oct 2021 07:08 AM PDT

The node Class is as follow:

class node  {      public:        int data; //the datum      node *next; //a pointer pointing to node data type  };  

The PrintList Function is as follow:

void PrintList(node *n)  {   while (n != NULL)      {          cout << n->data << endl;          n = n->next;      }  }  

If I try running it I get all three values (1,2,3) but I get an additional number as well which I'm unable to figure out what it represents, Can someone throw light on the same?

int main()  {        node first, second, third;      node *head = &first;      node *tail = &third;      first.data = 1;      first.next = &second;      second.data = 2;      second.next = &third;      third.data = 3;        PrintList(head);      }  

I Know it can be fixed with

third.next = NULL;  

But I am just curious what does this number represents in output, If I omit the above line

1  2  3  1963060099  

When RTCPeerConnection.onIcecandidate() event get invoked?

Posted: 30 Oct 2021 07:08 AM PDT

when sdp set to local? when answer set to remoteDescription? when any data or streams added to RTCPeerConnection?

Hardhat compile error "Expected a value of type HttpNetworkConfig"

Posted: 30 Oct 2021 07:07 AM PDT

I'm attempting to follow the NFT tutorial here. I have set up the accounts on Alchemy and Metamask created the .sol file. I have a .env file in root that looks like this:

API_URL = "https://eth-ropsten.alchemyapi.io/v2/your-api-key"  PRIVATE_KEY = "your-metamask-private-key"  

My hardhat config file looks like this:

/**    * @type import('hardhat/config').HardhatUserConfig    */    require('dotenv').config();    require("@nomiclabs/hardhat-ethers");    const { API_URL, PRIVATE_KEY } = process.env;    module.exports = {       solidity: {        compilers: [          {            version: "0.5.7"          },          {            version: "0.8.0"          },          {            version: "0.6.12"          }        ]      },       defaultNetwork: "ropsten",       networks: {          hardhat: {},          ropsten: {             url: API_KEY,             accounts: [`0x${PRIVATE_KEY}`]          }       },    }  

However when I try to compile I keep getting this error:

Invalid value {"url":"https://eth-ropsten.alchemyapi.io/v2/your-api-key","accounts":["0xyour-metamask-private-key"]} for HardhatConfig.networks.ropsten - Expected a value of type HttpNetworkConfig.

I cannot seem to figure out why this is not a valid value for HttpNetworkConfig. What I have where url is a string and accounts is an array would appear to comply with what is in the documentation for network configs. It's a compile error so it would seem it cannot be a problem with the actual url or private key, but maybe I'm wrong about that. I willingly admit to being a noob here with only a cursory understanding of hardhat, solidity, and even js, etc. Any help appreciated.

I want to add a babel plugin inside create-react-app

Posted: 30 Oct 2021 07:07 AM PDT

I want to add the following babel configuration in react-scripts I don't want to eject from cra I want to keep using it without ejecting. I see there is a way to fork the repo and add your custom configuration. But I want to know where exactly I can paste this.

// .babelrc or babel-loader option  {    "plugins": [      ["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css" }] // `style: true` for less    ]  }  

How to add a mapped network drive via VBS?

Posted: 30 Oct 2021 07:07 AM PDT

I'm having some issues with my vbs script. It will add only the F drive and not add the G driver after it. What am I doing wrong?

'## This is for network drives  Set objNetwork = CreateObject("WScript.Network")   objNetwork.RemoveNetworkDrive "F:", True, True    '## for adding  Set objNetwork = CreateObject("WScript.Network")  objNetwork.MapNetworkDrive "F:" , "\\myserver\share1"  objNetwork.MapNetworkDrive "G:" , "\\myserver\share2"  

IBM JVM Java Core Dump created on crash

Posted: 30 Oct 2021 07:07 AM PDT

I couldn't find a solution on other forums and websites so I thought I'd come here.

When I try to run an Information Server application (i.e. DataStage Infosphere Designer Client), it shows the copyright splash screen but it doesn't show the login screen. If I look at the Process tab in the task manager, I can see that the DataStage Infosphere Designer Client pops up then disappears (looks like something is killing the process). I also notice that 3 files are created in the software directory: Snap*****.trc, javacore*****.txt, and core*****.dmp

In the text file, I have the following:

NULL           ------------------------------------------------------------------------  0SECTION       TITLE subcomponent dump routine  NULL           ===============================  1TISIGINFO     Dump Event "gpf" (00002000) received   1TIDATETIME    Date:                 2014/12/10 at 18:17:57  1TIFILENAME    Javacore filename:    C:\IBM\InformationServer\Clients\Classic\javacore.20141210.181756.4956.0002.txt  1TIREQFLAGS    Request Flags: 0x81 (exclusive+preempt)  1TIPREPSTATE   Prep State: 0x100 ()  1TIPREPINFO    Exclusive VM access not taken: data may not be consistent across javacore sections  NULL           ------------------------------------------------------------------------  0SECTION       GPINFO subcomponent dump routine  NULL           ================================  2XHOSLEVEL     OS Level         : Windows XP 5.1 build 2600 Service Pack 2  2XHCPUS        Processors -  3XHCPUARCH       Architecture   : x86  3XHNUMCPUS       How Many       : 4  3XHNUMASUP       NUMA is either not supported or has been disabled by user  NULL             1XHEXCPCODE    J9Generic_Signal_Number: 00000004  1XHEXCPCODE    ExceptionCode: C0000005  1XHEXCPCODE    ExceptionAddress: 09C40340  1XHEXCPCODE    ContextFlags: 0001007F  1XHEXCPCODE    Handler1: 0846A120  1XHEXCPCODE    Handler2: 084CC0E0  1XHEXCPCODE    InaccessibleAddress: DD55B4BF  NULL             1XHEXCPMODULE  Module: C:\IBM\InformationServer\ASBNode\apps\jre\bin\j9ute24.dll  1XHEXCPMODULE  Module_base_address: 09C30000  1XHEXCPMODULE  Offset_in_DLL: 00010340  NULL             1XHREGISTERS   Registers:  2XHREGISTER      EDI: DD55B4BF  2XHREGISTER      ESI: 0853F2E0  2XHREGISTER      EAX: DD55B4BF  2XHREGISTER      EBX: 08FD96F0  2XHREGISTER      ECX: 08FDAB28  2XHREGISTER      EDX: DD55B4C0  2XHREGISTER      EIP: 09C40340  2XHREGISTER      ESP: 0028CA9C  2XHREGISTER      EBP: 08EA5D00  2XHREGISTER      EFLAGS: 00010216  2XHREGISTER      GS: 002B  2XHREGISTER      FS: 0053  2XHREGISTER      ES: 002B  2XHREGISTER      DS: 002B  NULL             1XHFLAGS       VM flags:00000000  NULL             NULL           ------------------------------------------------------------------------  0SECTION       ENVINFO subcomponent dump routine  NULL           =================================  1CIJAVAVERSION 1INTERNAL      An exception occurred attempting to access in-flight data. Internal diagnostics:  NULL             2INTERNAL                J9Generic_Signal_Number: 00000004  2INTERNAL                ExceptionCode: C0000005  2INTERNAL                ExceptionAddress: 093D12A0  2INTERNAL                ContextFlags: 0001007F  2INTERNAL                Handler1: 093DADC0  2INTERNAL                Handler2: 084CC0E0  2INTERNAL                InaccessibleAddress: DD55B4BF  NULL             2INTERNAL                Module: C:\IBM\InformationServer\ASBNode\apps\jre\bin\j9dmp24.dll  2INTERNAL                Module_base_address: 093D0000  2INTERNAL                Offset_in_DLL: 000012A0  NULL  0SECTION       MEMINFO subcomponent dump routine  NULL           =================================  1STHEAPFREE    Bytes of Heap Space Free: 2000000   1STHEAPALLOC   Bytes of Heap Space Allocated: 2000000   NULL             1STSEGTYPE     Internal Memory  NULL           segment  start    alloc    end       type     bytes  NULL             1STSEGTYPE     Object Memory  NULL           segment  start    alloc    end       type     bytes  1STSEGMENT     08540854 1A030000 1C030000 1C030000  00000009 2000000  NULL             1STSEGTYPE     Class Memory  NULL           segment  start    alloc    end       type     bytes  NULL             1STGCHTYPE     GC History    NULL             NULL           ------------------------------------------------------------------------  0SECTION       LOCKS subcomponent dump routine  NULL           ===============================  NULL             1LKPOOLINFO    Monitor pool info:  2LKPOOLTOTAL     Current total number of monitors: 0  NULL             1LKMONPOOLDUMP Monitor Pool Dump (flat & inflated object-monitors):  NULL             1LKREGMONDUMP  JVM System Monitor Dump (registered monitors):  2LKREGMON          Thread global lock (0x0898CFF0): <unowned>  2LKREGMON          Windows native console event lock lock (0x0898D044): <unowned>  2LKREGMON          NLS hash table lock (0x0898D098): <unowned>  2LKREGMON          portLibrary_j9sig_async_monitor lock (0x0898D0EC): <unowned>  2LKREGMON          getnameinfo monitor lock (0x0898D140): <unowned>  2LKREGMON          Hook Interface lock (0x0898D194): <unowned>  2LKREGMON          &(vm->bytecodeTableMutex) lock (0x0898D1E8): <unowned>  2LKREGMON          Hook Interface lock (0x0898D23C): <unowned>  2LKREGMON          dump tokens mutex lock (0x0898D290): <unowned>  2LKREGMON          MM_Forge lock (0x0898D2E4): <unowned>  2LKREGMON          MM_SublistPool lock (0x0898D338): <unowned>  2LKREGMON          MM_SublistPool lock (0x0898D38C): <unowned>  2LKREGMON          MM_SublistPool lock (0x0898D3E0): <unowned>  2LKREGMON          MM_SublistPool lock (0x0898D434): <unowned>  2LKREGMON          MM_SublistPool lock (0x0898D488): <unowned>  2LKREGMON          Undead Segment List Monitor lock (0x0898D4DC): <unowned>  2LKREGMON          Hook Interface lock (0x0898D530): <unowned>  2LKREGMON          Hook Interface lock (0x0898D584): <unowned>  2LKREGMON          MM_ParallelDispatcher::slaveThread lock (0x0898D5D8): <unowned>  2LKREGMON          MM_ParallelDispatcher::shutdownCount lock (0x0898D62C): <unowned>  2LKREGMON          MM_ParallelDispatcher::synchronize lock (0x0898D680): <unowned>  2LKREGMON          MM_WorkPackets::inputList lock (0x0898D6D4): <unowned>  2LKREGMON          MM_WorkPackets::allocatingPackets lock (0x0898D728): <unowned>  2LKREGMON          MM_GCExtensions::gcStats lock (0x0898D77C): <unowned>  2LKREGMON          &RAS_GLOBAL_FROM_JAVAVM(triggerOnGroupsWriteMutex,vm) lock (0x0898D7D0): <unowned>  2LKREGMON          &RAS_GLOBAL_FROM_JAVAVM(triggerOnTpidsWriteMutex,vm) lock (0x0898D824): <unowned>  2LKREGMON          &vm->verboseStateMutex lock (0x0898D878): <unowned>  2LKREGMON          VM thread list lock (0x0898D8CC): <unowned>  2LKREGMON          VM exclusive access lock (0x0898D920): <unowned>  2LKREGMON          VM Runtime flags Mutex lock (0x0898D974): <unowned>  2LKREGMON          VM Extended method block flags Mutex lock (0x0898D9C8): <unowned>  2LKREGMON          Async event mutex lock (0x0898DA1C): <unowned>  2LKREGMON          JIT/GC class unload mutex lock (0x0898DA70): <unowned>  2LKREGMON          VM bind native lock (0x0898DAC4): <unowned>  2LKREGMON          VM Statistics List Mutex lock (0x0898DB18): <unowned>  2LKREGMON          Field Index Hashtable Mutex lock (0x0898DB6C): <unowned>  2LKREGMON          VM class loader blocks lock (0x0898DBC0): <unowned>  2LKREGMON          VM class table lock (0x0898DC14): <unowned>  2LKREGMON          VM string table lock (0x0898DC68): <unowned>  2LKREGMON          VM segment lock (0x0898DCBC): <unowned>  2LKREGMON          VM JNI frame lock (0x0898DD10): <unowned>  2LKREGMON          VM GC finalize master lock (0x0898DD64): <unowned>  2LKREGMON          VM GC finalize run finalization lock (0x0898DDB8): <unowned>  2LKREGMON          VM memory space list lock (0x0898DE0C): <unowned>  2LKREGMON          VM JXE description lock (0x0898DE60): <unowned>  2LKREGMON          VM AOT runtime init lock (0x0898DEB4): <unowned>  2LKREGMON          VM monitor table lock (0x0898DF08): Flat locked by "(unnamed thread)" (0x0853F000), entry count 1  2LKREGMON          VM volatile long lock (0x0898DF5C): <unowned>  2LKREGMON          VM mem segment list lock (0x0898DFB0): <unowned>  2LKREGMON          VM mem segment list lock (0x0898E004): <unowned>  2LKREGMON          VM mem segment list lock (0x0898E058): <unowned>  2LKREGMON          FinalizeListManager lock (0x0898E0AC): <unowned>  2LKREGMON          &(jvmtiData->mutex) lock (0x0898E100): <unowned>  2LKREGMON          &(jvmtiData->redefineMutex) lock (0x0898E154): <unowned>  2LKREGMON          BCVD verifier lock (0x0898E1A8): <unowned>  2LKREGMON          XshareclassesVerifyInternTreeMon lock (0x0898E1FC): <unowned>  2LKREGMON          global mapMemoryBuffer mutex lock (0x0898E250): <unowned>  2LKREGMON          &(classLoader->mutex) lock (0x0898E2A4): <unowned>  2LKREGMON          Thread public flags mutex lock (0x0898E2F8): <unowned>  2LKREGMON          jvmriDumpThread lock (0x0898E34C): <unowned>  2LKREGMON          tracemon lock (0x0898E3A0): <unowned>  2LKREGMON          tracemon lock (0x0898E3F4): <unowned>  2LKREGMON          jvmriDumpThread lock (0x0898E448): <unowned>  NULL             NULL           ------------------------------------------------------------------------  0SECTION       THREADS subcomponent dump routine  NULL           =================================  NULL             1XMCURTHDINFO  Current thread  NULL           ----------------------  3XMTHREADINFO      "(unnamed thread)" J9VMThread:0x0853F000, j9thread_t:0x0896E124, java/lang/Thread:0x00000000, state:R, prio=0  3XMTHREADINFO1            (native thread ID:0x1898, native priority:0x5, native policy:UNKNOWN)  3XMTHREADINFO3           No Java callstack associated with this thread  3XMTHREADINFO3           Native callstack:  4XENATIVESTACK               unsubscribe+0xa210 (0x09C40340 [j9ute24+0x10340])  4XENATIVESTACK               JVM_OnUnload+0xbb0 (0x08A32D60 [j9trc24+0x2d60])  4XENATIVESTACK               J9VMDllMain+0x97c (0x08A3429C [j9trc24+0x429c])  4XENATIVESTACK               LdrUnloadDll+0x99 (0x77311320 [ntdll+0x41320])  4XENATIVESTACK               FreeLibrary+0x15 (0x76012D2C [KERNELBASE+0x12d2c])  4XENATIVESTACK               j9port_init_library+0x573d (0x084CCEFD [J9PRT24+0xcefd])  4XENATIVESTACK               RtlFreeHeap+0x7e (0x772FE023 [ntdll+0x2e023])  4XENATIVESTACK               (0x51E84D8D)  4XENATIVESTACK               (0x50FFCE8B)  4XENATIVESTACK               (0x8F8D5030)  NULL  NULL             1XMTHDINFO     Thread Details  NULL           ------------------  NULL             3XMTHREADINFO      Anonymous native thread  3XMTHREADINFO1            (native thread ID:0x1C84, native priority: 0x0, native policy:UNKNOWN)  3XMTHREADINFO3           Native callstack:  4XENATIVESTACK               NtWaitForMultipleObjects+0x15 (0x772F015D [ntdll+0x2015d])  4XENATIVESTACK               WaitForMultipleObjectsEx+0x8e (0x758119F8 [kernel32+0x119f8])  4XENATIVESTACK               GetCLRFunction+0xc7af (0x69C40FAE [clr+0xe0fae])  4XENATIVESTACK               GetCLRFunction+0xc705 (0x69C40F04 [clr+0xe0f04])  4XENATIVESTACK               GetCLRFunction+0xc634 (0x69C40E33 [clr+0xe0e33])  4XENATIVESTACK               BaseThreadInitThunk+0x12 (0x7581338A [kernel32+0x1338a])  4XENATIVESTACK               RtlInitializeExceptionChain+0x63 (0x77309F72 [ntdll+0x39f72])  4XENATIVESTACK               RtlInitializeExceptionChain+0x36 (0x77309F45 [ntdll+0x39f45])  NULL  3XMTHREADINFO      Anonymous native thread  3XMTHREADINFO1            (native thread ID:0x1D48, native priority: 0x0, native policy:UNKNOWN)  3XMTHREADINFO3           Native callstack:  4XENATIVESTACK               ZwWaitForSingleObject+0x15 (0x772EF8D1 [ntdll+0x1f8d1])  4XENATIVESTACK               WaitForSingleObjectEx+0x43 (0x75811194 [kernel32+0x11194])  4XENATIVESTACK               DllUnregisterServerInternal+0x5507 (0x69B70BF3 [clr+0x10bf3])  4XENATIVESTACK               DllUnregisterServerInternal+0x554e (0x69B70C3A [clr+0x10c3a])  4XENATIVESTACK               (0x69B6242D [clr+0x242d])  4XENATIVESTACK               LogHelp_TerminateOnAssert+0x2d0b6 (0x69C055BE [clr+0xa55be])  4XENATIVESTACK               LogHelp_TerminateOnAssert+0x2d40c (0x69C05914 [clr+0xa5914])  4XENATIVESTACK               GetMetaDataInternalInterface+0x17127 (0x69BD82F7 [clr+0x782f7])  4XENATIVESTACK               GetMetaDataInternalInterface+0x17195 (0x69BD8365 [clr+0x78365])  4XENATIVESTACK               GetMetaDataInternalInterface+0x17262 (0x69BD8432 [clr+0x78432])  4XENATIVESTACK               SetRuntimeInfo+0xef1 (0x69C4B5A1 [clr+0xeb5a1])  4XENATIVESTACK               GetPrivateContextsPerfCounters+0x5965 (0x69CF36F8 [clr+0x1936f8])  4XENATIVESTACK               BaseThreadInitThunk+0x12 (0x7581338A [kernel32+0x1338a])  4XENATIVESTACK               RtlInitializeExceptionChain+0x63 (0x77309F72 [ntdll+0x39f72])  4XENATIVESTACK               RtlInitializeExceptionChain+0x36 (0x77309F45 [ntdll+0x39f45])  NULL  3XMTHREADINFO      Anonymous native thread  3XMTHREADINFO1            (native thread ID:0x138C, native priority: 0x0, native policy:UNKNOWN)  3XMTHREADINFO3           Native callstack:  4XENATIVESTACK               NtWaitForMultipleObjects+0x15 (0x772F015D [ntdll+0x2015d])  4XENATIVESTACK               BaseThreadInitThunk+0x12 (0x7581338A [kernel32+0x1338a])  4XENATIVESTACK               RtlInitializeExceptionChain+0x63 (0x77309F72 [ntdll+0x39f72])  4XENATIVESTACK               RtlInitializeExceptionChain+0x36 (0x77309F45 [ntdll+0x39f45])  NULL  3XMTHREADINFO      Anonymous native thread  3XMTHREADINFO1            (native thread ID:0x5B4, native priority: 0x0, native policy:UNKNOWN)  3XMTHREADINFO3           Native callstack:  4XENATIVESTACK               ZwWaitForWorkViaWorkerFactory+0x12 (0x772F1F46 [ntdll+0x21f46])  4XENATIVESTACK               BaseThreadInitThunk+0x12 (0x7581338A [kernel32+0x1338a])  4XENATIVESTACK               RtlInitializeExceptionChain+0x63 (0x77309F72 [ntdll+0x39f72])  4XENATIVESTACK               RtlInitializeExceptionChain+0x36 (0x77309F45 [ntdll+0x39f45])  NULL  3XMTHREADINFO      Anonymous native thread  3XMTHREADINFO1            (native thread ID:0xBB8, native priority: 0x0, native policy:UNKNOWN)  3XMTHREADINFO3           Native callstack:  4XENATIVESTACK               ZwWaitForWorkViaWorkerFactory+0x12 (0x772F1F46 [ntdll+0x21f46])  4XENATIVESTACK               BaseThreadInitThunk+0x12 (0x7581338A [kernel32+0x1338a])  4XENATIVESTACK               RtlInitializeExceptionChain+0x63 (0x77309F72 [ntdll+0x39f72])  4XENATIVESTACK               RtlInitializeExceptionChain+0x36 (0x77309F45 [ntdll+0x39f45])  NULL  3XMTHREADINFO      Anonymous native thread  3XMTHREADINFO1            (native thread ID:0x7CC, native priority: 0x0, native policy:UNKNOWN)  3XMTHREADINFO3           Native callstack:  4XENATIVESTACK               ZwDelayExecution+0x15 (0x772EFD91 [ntdll+0x1fd91])  4XENATIVESTACK               Sleep+0xf (0x760144A5 [KERNELBASE+0x144a5])  4XENATIVESTACK               CoGetTreatAsClass+0x325e (0x74FFD98D [ole32+0x2d98d])  4XENATIVESTACK               CoGetTreatAsClass+0x314b (0x74FFD87A [ole32+0x2d87a])  4XENATIVESTACK               BaseThreadInitThunk+0x12 (0x7581338A [kernel32+0x1338a])  4XENATIVESTACK               RtlInitializeExceptionChain+0x63 (0x77309F72 [ntdll+0x39f72])  4XENATIVESTACK               RtlInitializeExceptionChain+0x36 (0x77309F45 [ntdll+0x39f45])  NULL  NULL           ------------------------------------------------------------------------  0SECTION       CLASSES subcomponent dump routine  NULL           =================================  1CLTEXTCLLOS     1CLTEXTCLLSS     2CLTEXTCLLOADER  3CLNMBRLOADEDLIB  3CLNMBRLOADEDCL  1CLTEXTCLLIB     1CLTEXTCLLOD     2CLTEXTCLLOAD    NULL           ------------------------------------------------------------------------  0SECTION       Javadump End section  NULL           ---------------------- END OF DUMP -------------------------------------  

Does anyone know how to read this file or know how to solve this issue?

I have already tried reinstalling the software, restarting my computer, reinstalling JRE and JDK. I'm not sure what else to do.

AngularJS: Using css media query for screen resize

Posted: 30 Oct 2021 07:07 AM PDT

I have an existing CSS, it does media query and displays a message box when the screen is resize to a certain size. I want the message box to disappear after 5 seconds.

Any idea how to do it in AngluarJs?

CSS:

@media all and (max-width: 1024px), all and (max-height: 760px) {    div#bestview {      display: block;      position:fixed;      z-index: 9999; /* above everything else */      top:0;      left:0;      bottom:0;      right:0;      background-image: url(../img/transpBlack75.png);    }  }  

HTML:

<div id="bestview">The selected browser size is not optimal for.....</div>  

Is it a bad practice to use a ThreadLocal Object for storing web request metadata?

Posted: 30 Oct 2021 07:07 AM PDT

I am working on a j2ee webapp divided in several modules. I have some metadata such as user name and preferences that I would like to access from everywhere in the app, and maybe also gather data similar to logging information but specific to a request and store it in those metadata so that I could optionally send it back as debug information to the user.

Aside from passing a generic context object throughout every method from the upper presentation classes to the downer daos or using AOP, the only solution that came in mind was using a threadlocal "Context" object very similar to a session BTW, and add a filter for binding it on ongoing request and unbinding it on response.

But such thing feels a little hacky since this breaks several patterns and could possibly make things complicated when it comes to testing and debugging so I wanted to ask if from your experience it is ok to proceed like this?

Floats, Decimals, or Integers

Posted: 30 Oct 2021 07:08 AM PDT

I have a rails app that process some data, and some of these data include numbers with decimals such as 1.9943, and division between these numbers and other integers. I wanted to know what the best way to store this was.

I thought of storing the numbers that would retain integers as integers and numbers that could become decimals as decimals. Although it was in a weird format like

#<BigDecimal:7fda470aa9f0,'0.197757E1',18(18)>   

it seems to perform the correct arithmetic when I divide two decimal numbers or a decimal with an integer. When I try to divide integers with integers, it doesn't work correctly. I thought rails would automatically convert the result into a proper decimal, but it seems to keep it as integer and strip the remainders. Is there anything I can do about this?

And what would be the best way to store this type of information? Should I store it all as decimals, or maybe floats?

No comments:

Post a Comment