Sunday, June 27, 2021

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


how to make a Function Call?

Posted: 27 Jun 2021 09:46 AM PDT

I have a problem when executing my function, I have been putting it in the main but it does not execute (it does not mark any error either) and I have been trying to execute it in the previous function (Column) but it does not allow me to execute it unless it is within the first for, otherwise it still cannot be executed, I have implemented an if condition, so that the call of the function is not repeated the n times that lasts the for cycle but I have realized that this condition generates that the matrix M

void Renglon(){      int etapa;    int  z=0;          for(i=0; i <= N-1; i++) {             for(n=0; n< N; n++){            x[n] = MC[i][n];                                      init_bro();                    init_W();                   ordena_ent();                                 for(etapa=1; etapa <= nbits; etapa++){                      combina(etapa);                      }                      }                    z=z+1;        printf("\n\n Salida = (%d) ", z);           for(m=0; m<N; m++)             printf("\n x[%d] = %.2f + %.2f j", m, creal(mcombina[m][3]), cimag(mcombina[m][3]));           //printf("\n x[%d,%d] = %.2f + %.2f j", m,i, creal(MC[m][7]), cimag(MC[m][7]));    }    }  void Columna(){      int etapa;      int g = 0;      int z=0;            for(n=0; n <=64 ; n+=8, j=1+j)          {              for(i=0; i <= N-1; i++){                   x[i] = (double)data[n+i][0] + data[n+i][1]*I;                              init_bro();                   init_W();                   ordena_ent();                                   }             for(etapa=1; etapa <= nbits; etapa++){              combina(etapa);          }                                 for(i=0; i <= N-1; i++) {                  MC[i][j] = mcombina[i][3];                  //MT[i][j]=MC[i][1];               g=g+1;                  }                       if(g==8){         Renglon();       }  }          }              int main(int argc, char const *argv[])  {      /* code */      if (argc < 3){          printf("Please specify the CSV file as an input.\n");          exit(0);      }        char row     = atoi(argv[1]);      char col     = atoi(argv[2]);      char fname[256];    strcpy(fname, argv[3]);        data = (double **)malloc(row * sizeof(double *));      for (int i = 0; i < row; ++i){          data[i] = (double *)malloc(col * sizeof(double));      }   int etapa;      read_csv(row, col, fname, data);      Columna();      Renglon();  return 0;      }  

Pyinstaller not working well with ttkbootstrap library

Posted: 27 Jun 2021 09:46 AM PDT

I have a simple GUI which I designed with tkinter & ttkbootstrap.

Everything works fine when I run the script with my IDE.

Also, The main.exe file is created successfully with Pyinstaller by using this command: pyinstaller.exe --onefile main.py.

Finally I get this Information: 456865 INFO: Building EXE from EXE-00.toc completed successfully.

But when I'm trying to run main.exe which located in: C:\Users\benja\Desktop\simpleGUI\dist I get this error:

enter image description here

I'll appreciate any help to solve this error.

SFML Text will not appear. what should i do?

Posted: 27 Jun 2021 09:46 AM PDT

I am tring to make a text draw in to my window
but what ever i do will not work. I just started learning SFML. I read the documentation to. I don't know what to do I'm stuck at this point. Please look at my code and tell me what's wrong.

#include <iostream>  #include <SFML/Graphics.hpp>    int WIDTH = 600;  int HEIGHT = 600;    int main(){      sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), "Pokemon");      sf::Event event;              // Textures      sf::Texture poke;      poke.loadFromFile("res/logo.png");        sf::Font font;      font.loadFormFile("arial.ttf");        sf::Text start;      start.setFont(sf::Font::GetDefaultFont());      start.setString("hello");      start.setScale(2.f, 2.f);        sf::Sprite Pokemon(poke);      Pokemon.setPosition(55, 75);      Pokemon.setScale(sf::Vector2f(0.4f, 0.4f));        while(window.isOpen()){          window.setFramerateLimit(30);            while (window.pollEvent(event)){              if (event.type == sf::Event::Closed){                  window.close();              }          }            window.clear(sf::Color::Blue);            window.draw(Pokemon);          window.Draw(start);          window.display();      }        return EXIT_SUCCESS;  }  

CSS accordion opens on click, but won't close! Help would be appreciated

Posted: 27 Jun 2021 09:46 AM PDT

I've got a pure CSS accordion partly working on my site. It opens on click, however for some reason it won't close when clicked again.

I've tried lots of tweaks to try and get this sorted but nothing's helped so I'd love to know if anybody here could work it out for me.

The exact code I'm using is here on CodePen and pasted below.

.gohere-accordion {      margin-top: 7px;      margin-bottom: 7px;      margin-left: 4px;      margin-right: 15px;          width: 99%;          color: #484848;  }  .gohere-accordion input {      display: none;  }  .gohere-box {      position: relative;      background: white;          height: 64px;          transition: all .15s ease-in-out;          color: #484848;  }  .gohere-box::before {      content: '';      position: absolute;      display: block;      top: 0;      bottom: 0;      left: 0;      right: 0;      pointer-events: none;      box-shadow: 0 -1px 0 #e5e5e5,0 0 2px rgba(0,0,0,.12),0 2px 4px rgba(0,0,0,.24);  }  gohere-header.box {      background: #00BCD4;          color: #484848;      z-index: 100;      cursor: initial;      box-shadow: 0 -1px 0 #e5e5e5,0 0 2px -2px rgba(0,0,0,.12),0 2px 4px -4px rgba(0,0,0,.24);  }  gohere-header .gohere-box-title {      margin: 0;      font-weight: normal;      font-size: 16pt;          color: #484848;      cursor: initial;  }  .gohere-box-title {      width: calc(100% - 40px);      height: 64px;      line-height: 64px;      padding: 0 20px;      display: inline-block;      cursor: pointer;          color: #484848;      -webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;  }  .gohere-box-content {      width: calc(100% - 40px);      padding: 30px 20px;      font-size: 11pt;          color: #484848;      color: rgba(0,0,0,.54);      display: none;  }  .gohere-box-close {      position: absolute;      height: 64px;      width: 100%;      top: 0;      left: 0;      cursor: pointer;      display: none;  }  input:checked + .gohere-box {      height: auto;      margin: 16px 0;      box-shadow: 0 0 6px rgba(0,0,0,.16),0 6px 12px rgba(0,0,0,.32);  }  input:checked + .gohere-box .gohere-box-title {      border-bottom: 1px solid rgba(0,0,0,.18);  }  input:checked + .gohere-box .gohere-box-content,  input:checked + .gohere-box .gohere-box-close {      display: inline-block;  }  .arrows section .gohere-box-title {      padding-left: 44px;      width: calc(100% - 64px);  }  .arrows section .gohere-box-title:before {      position: absolute;      display: block;      content: '\203a';      font-size: 18pt;      left: 20px;      top: -2px;      transition: transform .15s ease-in-out;      color: rgba(0,0,0,.54);  }  input:checked + section.gohere-box .gohere-box-title:before {      transform: rotate(90deg);  }
<nav class="gohere-accordion"><!-- THEN ONE OF THESE PER SINGLE ACCORDION --><input id="cb1" name="gohere-accordion" type="radio" />  <section class="gohere-box"><label class="gohere-box-title" for="cb1">This is a frequently asked question - opens, but won't close!</label>    <div class="gohere-box-content">Now it's open, how can I make it close on click?</div>  </section>  </nav>

Resolving a promise in React

Posted: 27 Jun 2021 09:46 AM PDT

I'm new to Front end dev and am facing this scenario where I'm trying to do some action after a promise (from making an API call) is resolved.

This is the code snippet.

<api-call>      .then((res) => {          // promise resolving code          });  

The expected structure of the API response:

{      "success": true,      "message": "Message Text"  }  

When running the application, the API returns the specified response (shown in Network response), but while inspecting the res object doesn't hold the same data.

The response is

{      "success": false      "message": undefined  }  

The promise is resolved and the corresponding block is executed but raises errors due to incorrect response.

I tried using an await before the API call, but it still doesn't work. Am I missing something else here?

anonymize rdbms datas, keeping key relations

Posted: 27 Jun 2021 09:45 AM PDT

Is there a "ready-to-use" method to anonymize datas, but keeping relations between keys ? For example, I have :

  • Table #1
user code zip code
ztxp15 45789

And :

  • Table #2
user code order date
ztxp15 2021-06-27 06:22pm

I want it anonymized as :

user code zip code
xvdf65 32165

And :

  • Table #2
user code order date
xvdf65 2021-06-27 06:22pm

This would need : a bijective function that transform a data, keeping its format ([a-z]{4}[0-9]{2}), generating the same value, according a passphrase for example. In this way, unicity will be kept, format too, etc. But maybe I miss something. I think that this problematic is very common so I am looking for previous work about it.

React typescript interface only one of two required

Posted: 27 Jun 2021 09:45 AM PDT

I was wondering how I can require one of the properties in the interface. I don't want to require both HideBelow and HideAbove but only one of them. How would I go about implementing that? There needs to be either below={HideBelow} or below={HideAbove} in the component.

<Example below={HideBelow} />  
<Example below={HideAbove } />  
interface TableContentProps {      Data?: any;      HideType: "above" | "below" | "none";      HideBelow?: "sm" | "md" | "lg" | "xl";      HideAbove?: "sm" | "md" | "lg" | "xs";  }  

Android in-app update Error NullPointerException

Posted: 27 Jun 2021 09:45 AM PDT

  appUpdateManager = AppUpdateManagerFactory.create(getApplicationContext());    Task<AppUpdateInfo> appUpdateInfoTask = appUpdateManager.getAppUpdateInfo();    appUpdateInfoTask.addOnSuccessListener(appUpdateInfo -> {       if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE               && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)) { (AppUpdateType.IMMEDIATE || AppUpdateType.FLEXIBLE)          requestUpdate (appUpdateInfo);      }  });      java.lang.NullPointerException:     at com.hamletshu.qrcheckin.MainActivity.lambda$onCreate$0$MainActivity (MainActivity.java:77)    at com.hamletshu.qrcheckin.-$$Lambda$MainActivity$_uNPm6i34VjwR8GMooC8flu4-A4.onSuccess (Unknown Source:4)    at com.google.android.play.core.tasks.e.run (Unknown Source:27)    at android.os.Handler.handleCallback (Handler.java:873)    at android.os.Handler.dispatchMessage (Handler.java:99)    at android.os.Looper.loop (Looper.java:214)    at android.app.ActivityThread.main (ActivityThread.java:7050)    at java.lang.reflect.Method.invoke (Native Method)    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:494)    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:965)  

I used the Android in-app update as it is by referring to the Google documentation, but the error appears. What should I do?

Display different time period for different days in Calender using JQuery daterangepicker

Posted: 27 Jun 2021 09:46 AM PDT

I have 2 questions

1)I want to display different time value for different days (like Saturday and Sunday) in Calender. I don't know how to implement this with JQuery daterangepicker.

2)I am trying to increase Hours by 3 hours using " timePickerIncrement: 180, " But It's not working. I think i missing something.

Can anyone help me to solve this problem?

enter code here    $('.date-time-range').daterangepicker({      locale: {          format: 'YYYY-MM-DD h:mm A'      },      isInvalidDate: function(date) {      if (date.day() == 0 || date.day() == 5 || date.day() == 6)        return false;      return true;      },      timePicker: true,      singleDatePicker: true,      timePickerIncrement: 180,      minDate: '<?php echo $todayDate;?>',      startDate:'<?php echo $startDate;?>',      drops: 'down',      buttonClasses: "btn btn-sm",      applyClass: "btn-success1"  });  

enter image description here

I need to help for wordpress setup

Posted: 27 Jun 2021 09:45 AM PDT

Please help me for install wordpress in IIS server. I tried but i still found a 403 error.

Click here

Values's onHorizontalDragUpdate not return correct value

Posted: 27 Jun 2021 09:44 AM PDT

GestureDetector(          child: myWidget,          onHorizontalDragUpdate: (DragUpdateDetails details) {            print('dx: ${details.globalPosition.dx}')            ///only print             ///xxx.0            ///xxx.5            ///(x + 1).0            ///This is only 3 sections in 1 unit          },        ),  

onHorizontalDragUpdate not return correct value
Expect: when drag => i need to full value
For example:
0.001xxx
0.002xxx
0.003xxx
0.xxxxxx
1.xxx**

Is it not correct to do api call without useEffect?

Posted: 27 Jun 2021 09:44 AM PDT

I want to do an api call after a button is clicked in react.But I have read that to do async tasks, we use useEffect. So is it okay to not use useEffect and do an api call without it? I think that without using useEffect an api call would block the render. So,What is the correct way to do an api call if it has to be done on Click?

How to use the ISEMPTY function

Posted: 27 Jun 2021 09:45 AM PDT

I am learning SQL and using Myworkbench to do so. The error is pointing to the isempty function. Where am I going wrong?

SELECT a.ParcelID, a.PropertyAddress, b.ParcelID, b.PropertyAddress,   isempty(a.propertyAddress,b.propertyAddress)   FROM portfolioproject.nashvillehousing a  join nashvillehousing b  on a.ParcelID = b.ParcelID  and a.UniqueID <> b.UniqueID  where a.PropertyAddress = '';  

Error in mysql #1241 — The operand must contain 1 columns. How do I make an alternative working request?

Posted: 27 Jun 2021 09:46 AM PDT

I understand that in the IN operator, and more precisely in SELECT, it is impossible to select two columns. Could you write an alternative of the same query or fix this one.

SELECT *   FROM `board`   WHERE moder=0 AND activ=0 AND id_akk IN (SELECT user_id_to, user_id_from                                                                                    FROM `podpiski`                                            WHERE user_id_from='38')  

How to create a object with numbers 500 at 524 without going one by one

Posted: 27 Jun 2021 09:47 AM PDT

I want to create and then replace in a string, would it be able to appear in the object 500 up to 524 without having to go from 1 to 1? I hope it's understandable with the examples

const numbers = {    500: "20"  }    console.log(user.list.map(list => numbers[user.points]))  

e.g.:

const numbers = {    500 at 524: "20",    600 at 650: "25"  }  

way that works, but it would be too much big:

const numbers = {  "500": "20",  "501": "20",  "502": "20",  "503": "20",  (...)  }  

if this is not possible, let me know that I will delete the question.

Why is there no difference between variables in Python?

Posted: 27 Jun 2021 09:44 AM PDT

I am a beginner in Python and just starting to learn from home. I did an exercise on creating a list containing friends and print them one by one. Then, I need to print them one by one including a message. The text of each message should be the same, but each message should be personalized with the person's name. So, this is the first code:

names = ['John','Ben','Daniel','Nathan']  greetingJohn = f"Good morning {names[0]}."  print(greetingJohn)  greetingBen = f"Good morning {names[1]}."  print(greetingBen)  greetingDaniel = f"Good morning {names[2]}."  print(greetingDaniel)  greetingNathan = f"Good morning {names[3]}."  print(greetingNathan)  

This is the second code:

names = ['John','Ben','Daniel','Nathan']  greeting = f"Good morning {names[0]}."  print(greeting)  greeting = f"Good morning {names[1]}."  print(greeting)  greeting = f"Good morning {names[2]}."  print(greeting)  greeting = f"Good morning {names[3]}."  print(greeting)  

The output is the same for both:

Good morning John.  Good morning Ben.  Good morning Daniel.  Good morning Nathan.  

So, I am confused why is there no difference between the 'greeting{name}' and only 'greeting'? Hopefully, you can answer my curious beginner question.

How to make a backspace button work on HTML calculator?

Posted: 27 Jun 2021 09:45 AM PDT

Trial 1 - Within the same HTML file - Head - enter code here function backSpace() { var bsp = document.getElementById("ns").value; document.getElementById("ns").value=bsp.substring(0,bsp.length -1); }

Body -

"Backspace"

Trial 2 Is there a way to use "--" of the existing value and just backspace without using fuctions?

How to pass column names of pandas dataframe in python function? [closed]

Posted: 27 Jun 2021 09:45 AM PDT

Suppose I have following pandas dataframe named mtcars:

Name mpg cyl disp hp drat wt qsec
Mazda 21 6 160 110 3.9 2.6 16
Dastun 22.8 4 108 93 3.8 2.8 17

I want to calculate some parameters using function which I can write as follow:

def smr(df, by, colnm):      result= df[colnm].groupby(by).agg(['sum', 'mean'])      return result    sm1 = smr(mtcars, 'cyl', ['cyl','disp', 'hp', 'drat', 'wt', 'qsec'])  

But I want to improve this function so that I can pass a single column or multiple columns for aggregation.

Delete clicked item of a list fetched from MongoDB

Posted: 27 Jun 2021 09:46 AM PDT

I want to be able to delete items of a list fetched from MongoDB.

Items of an array of the list are retrieved from MongoDB and displayed in React app.

How can I pass the id of the item that is clicked to the to DeleteListItem() function and then to axios.delete()? Thanks!

ExpensesListItem.tsx (HERE I should pass id of the item to axios.delete('http://localhost:4000/app/expenseslist') somehow)

import React from "react";  import { IconButton, ListItem, ListItemSecondaryAction, ListItemText } from "@material-ui/core";  import DeleteIcon from '@material-ui/icons/Delete';  import { ExpenseAndAmountObject } from '../ExpenseAndAmountObject';  import axios from 'axios';  interface Props {      expenseTitle: string;      expenseAmount: string;      currencySymbol: string;      item: ExpenseAndAmountObject;      expenseAndAmountList: Array<ExpenseAndAmountObject>;      setExpenseAndAmountList: (value: Array<ExpenseAndAmountObject>) => void;    }    const ExpensesListItem: React.FC<Props> = (      {          expenseTitle,          expenseAmount,          currencySymbol,          item,          expenseAndAmountList,          setExpenseAndAmountList      }: Props) => {        const DeleteListItem = () => {          setExpenseAndAmountList(expenseAndAmountList.filter(el => el._id !== item._id));            axios.delete('http://localhost:4000/app/expenseslist')          .catch(function (error) {              console.log(error);          });      }        return (          <>              <ListItem className="list-item">                  <ListItemText primary={expenseTitle} secondary={expenseAmount + currencySymbol} />                  <ListItemSecondaryAction>                      <IconButton onClick={DeleteListItem} edge="end">                          <DeleteIcon className="delete-btn" />                      </IconButton>                  </ListItemSecondaryAction>              </ListItem>          </>        );    }      export default ExpensesListItem;  

routes.js

 router.delete('/expenseslist', (request, response) => {      ExpenseAndAmountTemplate.findByIdAndRemove(request.params.id, function(err){          if(err){              response.redirect("/Could not delete the item...");          } else {              response.redirect("/Expenses and amount item was deleted succesfully...");          }       });   });    router.post('/expenseslist', (request, response) => {      const ExpenseAndAmountItem = new ExpenseAndAmountTemplate({       expenseTitle:request.body.expenseTitle,       expenseAmount:request.body.expenseAmount,   });   ExpenseAndAmountItem.save()   .then(data => {       response.json(data);   })   .catch(error => {       response.json(error);   });   });  

Python Read range of lines from txt on a server and write them to local file

Posted: 27 Jun 2021 09:45 AM PDT

I have a log file on a remote server and I want to write to a file the lines i have chosen to write.

The thing is that print(linex) below is OK and I see all lines in CMD console. But it is writing only the 1st line to the file.

What am I missing here...?

def GetEndLastLine ():      last_line = sum(1 for line in open('//10.10.10.10/d$/log/server.log'))      print(last_line)          with open('//10.10.10.10/d$/log/server.log') as f:          for linex in itertools.islice(f, first_line, last_line):              break          x = open(r"LogFile.txt", "w")                  print(linex)                  x.write("LOGS START HERE****\n\n"+ output +"")                  os.system("start notepad++.exe LogFile.txt")  

How can I get a YouTube video upload date with Selenium in Python?

Posted: 27 Jun 2021 09:46 AM PDT

I've been trying to get the upload date of a YouTube video (as the following picture shows) using Selenium:

enter image description here

My code is as follows:

! pip install selenium  from selenium import webdriver  ! pip install beautifulsoup4  from bs4 import BeautifulSoup    driver = webdriver.Chrome('D:\chromedrive\chromedriver.exe')  driver.get("https://www.youtube.com/watch?v=CoR72I5BGUU")  soup = BeautifulSoup(driver.page_source, 'lxml')    upload_date=driver.find_elements_by_xpath('//*[@id="info-strings"]/yt-formatted-string')    print(upload_date)  

However, no matter I used

upload_date=soup.findAll('span', class_='style-scope ytd-grid-video-renderer')  

or

upload_date=driver.find_elements_by_xpath('//*[@id="info-strings"]/yt-formatted-string')  

it didn't work.

If anyone knows where the problem is, please help me.

How can I test sending Ether to a contract with a `payable` function?

Posted: 27 Jun 2021 09:46 AM PDT

I am writing Hardhat tests for a Solidity contract I've written. The contract contains a receive() external payable { ... } function. How can I call this from a test with an Ether amount?

Can I embed multiple content addins into a single document

Posted: 27 Jun 2021 09:45 AM PDT

We'd like to create an addin where we could provide some custom visualisation to embed within office documents (excel, word, ppt ideally), but be able to embed multiple content in each document (page / sheet / slide etc)

Does the content addin provide this functionality?

Match every row in a dataframe to each row in another dataframe in r

Posted: 27 Jun 2021 09:46 AM PDT

This might be a simple question, but I couldn't seem to find an obvious solution.

I have two data frames, df1 with 64 rows, and df2 with 662,343 rows. I essentially want to left join df1 to df2, where every row in df1 is mapped to each row in df2, so that I end up with 42,389,952 rows. df1 and df2 might look like this respectively:

df1: | Cancer | ID | |---------------------|------------------| | Sarcoma | 3435 | | Leukemia | 4465 |

df2:

Gene
TP53

new data frame :

Cancer ID Gene
Sarcoma 3435 TP53
Leukemia 4465 TP53

Thanks in advance for any help!

create dylib file for iOS app development from visual studio c++ project

Posted: 27 Jun 2021 09:46 AM PDT

I have a Visual Studio C++ project. This project has the functionality for correction the fish-eye images into the original rectangular image files. I want to use this functionality in my iOS app development by inserting dylib library file.

How can I create it from my C++ project? Is there any guide for this one? Thanks in advance.

create shared object .so file for android from visual studio C++ proejct

Posted: 27 Jun 2021 09:45 AM PDT

I have a Visual Studio C++ project. This project is responsible for correcting the fish-eyed images into the original rectangular image files. I want to create a shared object .so file from this project to use in the android app for development. So, just make the library file for android app development.

How to realize it? Is there any guide to help me? Thanks in advance.

Make an API for android and iOS with python or c

Posted: 27 Jun 2021 09:45 AM PDT

Respected developers. Hoping you are doing well, beating the COVID-19. Is there anyone who can help me with my problem?

I want to make an API that will do some functionalities in mobile app both for android and iOS.
But I don't know native android or iOS, so I want to make the dynamic library file like .so with python, and then export it to embed it on android or iOS project. By doing this, I can import that files to use it. Is this possible? Is there any way to make dynamic library files from python code? How to use the dynamic files in android and iOS? What is the best solution to make the custom API for android and iOS mobile apps?

I will be happy if someone guides me how to do it. Thanks in advance. Denis.

ADD: if cannot python, how about c? who can help me?

Confusion about different meanings of "HighMem" in Linux Kernel

Posted: 27 Jun 2021 09:46 AM PDT

I'm trying to understand what "highmem" means but I've seen it used in two different ways and I want to know if one or both are correct.

The two definitions I've gleaned are:

  1. Highmem refers to a specific situation in 32 bit systems, where the system could fit more than 4GB of RAM but 32 bits only allowed the kernel to address 4GB memory directly, so any memory above 4GB needed to use Physical Address Extensions (PAE) and was called "highmem". When I see this version of high memory discussed, usually it's mentioned that 64 bit systems no longer have this problem; they can address their physical memory fully so no notion of "highmem" is needed (see 1, 2, 3). My own 64-bit system doesn't show any highmem memory in /proc/zoneinfo or in free -ml.

  2. Highmem is used to describe the virtual memory address space that is for user-space. This is in contrast with lowmem, the address space that is used for the kernel and is mapped into every user-space program's address space. Another way I've seen this phrased is with the names zone_highmem (highmem) and zone_normal (lowmem). For instance, in the 32-bit system "3/1" user/kernel memory split, the 3GB used for user space would be considered high memory (see 4, 5, 6, 7).

Is one definition more correct than another?

Are both correct but useful in different situations (i.e. definition 1 referring to physical memory, definition 2 referring to virtual memory)?

Python - Fastest way to find all perfect squares in a given large number range

Posted: 27 Jun 2021 09:45 AM PDT

I am trying to write a method to get all the perfect squares in a given range in Python. A large range like between 2621163 and 520001400002. Now obviously iterating through the range and checking if a number is perfect like so

def is_square(n):      return math.sqrt(n).is_integer()  

and then printing it is stupid for large ranges (works great for small ranges) and will take forever. I am wondering if there is any Python magic or mathemagic (say a modified Diophantine equation) that I can leverage for this purpose.

EDIT: Also I am using Python 3.X so I can use large integers.

lowering priority of Task.Factory.StartNew thread

Posted: 27 Jun 2021 09:46 AM PDT

a code like below will start a new thread to do the job. Is there any way I can control the priority of that thread?

Task.Factory.StartNew(() => {      // everything here will be executed in a new thread.      // I want to set the priority of this thread to BelowNormal  });  

No comments:

Post a Comment