Thursday, March 31, 2022

Recent Questions - Stack Overflow

Recent Questions - Stack Overflow


Bootstrap 5 floating label on top of the field

Posted: 31 Mar 2022 12:55 AM PDT

I want to put the floating label just like this: enter image description here

The normal behaviour would be this but the input area is way to big for my purpose. enter image description here

I don't have an idea how to set this up. For Bootstrap 4 there was an extra framework but this won't work with V5.

Thanks in advance!

How to invite someone to work on only a branch in Git and Github?

Posted: 31 Mar 2022 12:55 AM PDT

I have created a GitHub repo and I want to invite someone else to work on only a branch of that repo so that they cannot make changes to the master or any other branch or merge branches. Simply put I don't want to invite them as a collaborator but to work on only one branch.

I tried to invite them as collaborator and create branch rules but ended up making an error when I tried to push in the master branch as well.

how to send Content-Length in rest assure ,Since encountering error that "Content-Length header already present"

Posted: 31 Mar 2022 12:55 AM PDT

I am performing post operation using RestAssure and where in header I am passing Content-Length as below - queryParam().header("Content-Length", "value_Of_It")

and due to that, I am encountering the error that "Content-Length header already present". it would be great if someone can help me out to resolve it ?

Caused by: org.apache.http.ProtocolException: Content-Length header already present

Default construct tuple of references from variadic template

Posted: 31 Mar 2022 12:55 AM PDT

template<typename... T>  struct RoundRobin  {      // Dangling references      RoundRobin() : choices{std::forward_as_tuple(T{}...)}      {}        // Expected behaviour      RoundRobin(std::in_place_t, T&... c) : choices{std::forward_as_tuple(c...)}      {}        std::tuple<T&...> choices;  };    struct Choice {};    // OK  Choice c1, c2, c3;  RoundRobin good_robin(c1, c2, c3);    // NOT OK  RoundRobin<Choice, Choice, Choice> bad_robin;  

I would like the provide the ability to both default construct the following struct (as well as inject respective choices).

After default construction, however, the choices tuple is initialized with seemingly dangling references and any access attempts result in a segfault.

Is there anyway I can default construct my choices tuple (and maintain the existing functionality of reference injection)?

Thanks

Reading a large file from S3 into a dataframe

Posted: 31 Mar 2022 12:55 AM PDT

when i try to read a file more than 2GB in size to a dataframe i get followinbg error: OverflowError: signed integer is greater than maximum

this is as mentioned in https://bugs.python.org/issue42853

is there a workaround for this?

React Cookie doesn't work with async response

Posted: 31 Mar 2022 12:55 AM PDT

Hello I am working on a React application (an e-commerce). I noticed that when I try loading all the product on a first render, it takes about 9 seconds (Load time is similar to what I got on Postman as well). However, I am trying to improve the load time by caching the data in a cookie so I decided to try out React-Cookie library. However, I noticed that when I tried to save the response data from my API call (asynchronous), My cookie doesn't get set with the data but it works well with hard-coded synchronous value. I have looked through the React-cookies documentation and I couldn't find any solution to this problem. Any suggestion or pointer to how this issue can be solved would be greatly appreciated. Thank you.This is for the async data This is for the hard-coded synchronous dataThis is the component where the two functions are called This is what is available in my browser cookie

how can I replicate this on vue

Posted: 31 Mar 2022 12:54 AM PDT

enter image description here

I'm trying to replicate this on Vue, the date is coming from an array I have something like this

<h1>{{ mydate | formatDate }}</h1  

how extract fields from text into Excel?

Posted: 31 Mar 2022 12:54 AM PDT

Extract fields from text into Excel, for example: "1.where are you from? A china B usa. the correct answer is B。2.what's your name? A Jone B jack. the correct answer is A。"

The Excel should be like the follow:

enter image description here

I don't know how to try?I am currently manual input, very slow!

Ansible get all hosts in subgroup

Posted: 31 Mar 2022 12:54 AM PDT

I have the following hosts structure in the inventory:

all:    children:      sc:        hosts:          sc-finder01a.com:          sc-finder01b.com:        vars:          default_port: 5679          version: 0.4.2-RELEASE      ms:        hosts:          ms-finder01a.com:          ms-finder01a.com:        vars:          default_port: 5679          version: 0.4.2-RELEASE  

I'm running on all hosts, where for each host I'd like to access the other one in the subgroup (sc/ms) in order to check a condition before executing it on the current host, but I'm struggling to find the syntax. Also, I have to prevent Ansible from executing the command on two hosts in the same subgroup in parallel.

Ideas?

How to access keyframes & webkit transform in javascript?

Posted: 31 Mar 2022 12:55 AM PDT

I want to create a circular progressbar in Html, Javascript and css.

This here is my code:

<div class="progress blue"> <span class="progress-left"> <span class="progress-bar"></span> </span> <span class="progress-right"> <span class="progress-bar"></span> </span>                    <div class="progress-value">70%</div>                </div>  
@keyframes loading-2 {      0% {          -webkit-transform: rotate(0deg);          transform: rotate(0deg)      }        100% {          -webkit-transform: rotate(50deg);          transform: rotate(50deg)      }  }  

I have found following answer to my question on stackoverflow

element.style.webkitTransform = "rotate(-2deg)";  

but I have 2 keyframes and 2 webkit transform elements, so how can I select the 2nd one?

the 1 that I want to access is the

100% {          -webkit-transform: rotate(50deg);          transform: rotate(50deg)      }  

how can I do this in javascript so I can make my progress bar dynamically?

I tried to use this answer here: How to set the style -webkit-transform dynamically using JavaScript?

but as I said I have 2 keyframe elemnts and 2 webkit transform elements and I cant acces them with element.style.webkitTransform = "rotate(-2deg)";

SpringBoot H2 Database loosing data in the every execute

Posted: 31 Mar 2022 12:55 AM PDT

I connected to h2 database and i'm posting the entity while using postman. But I loose the data everytime when I rerun the my code.

      spring.h2.console.enabled=true        spring.datasource.url = jdbc:h2:mem:crm/db_;DB_CLOSE_DELAY=-1        spring.datasource.driver-class-name=org.h2.Driver        spring.datasource.username=sa        spring.datasource.password=        spring.jpa.show-sql=true        spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect        spring.jpa.hibernate.ddl-auto=update  

Is there anyway to storage data in H2Database?

incompatible types boolean can not be converted to char

Posted: 31 Mar 2022 12:54 AM PDT

public class WordPlay {      public  boolean isVowel(char ch){          String vowels ="aeiouAEIOU";          int i;          for( i = 0; i < vowels.length(); i= i+1) {              char Char = vowels.charAt(i);               if (Char == ch){                  return true;              } else {                  return false;              }            }      }    public void testIsVowel() {          char Value = isVowel ('a');           System.out.println(Value);   

I'm getting an error saying cannot convert boolean to char for line 15. My last method is a tester method to see if the isVowel char will print true or false for any char that I place in there. Very new to Java don't know how to continue from here.

Web Scraping with JS - module not defined

Posted: 31 Mar 2022 12:54 AM PDT

I am working on a project where I'm scraping stock prices.

I am able to get the stock price in the console (from pageScraper.js file), but it's refusing to display in the DOM.

I keep getting an error that says "module not defined". I am asking because after hours of research, I give up and need some advice.

Here's my code - feel free to use it if you're interested in the scraping part.

index.html

<!DOCTYPE html>  <html lang="en">  <head>      <meta charset="UTF-8">      <meta http-equiv="X-UA-Compatible" content="IE=edge">      <meta name="viewport" content="width=device-width, initial-scale=1.0">      <script src="pageScraper.js">      </script>       <title>Document</title>  </head>  <body>        <div id="demo"></div>  </body>  </html>  

browser.js

const puppeteer = require('puppeteer');    async function startBrowser() {    let browser;    try {      console.log('Opening the browser......');      browser = await puppeteer.launch({        headless: false,        args: ['--disable-setuid-sandbox'],        ignoreHTTPSErrors: true,      });    } catch (err) {      console.log('Could not create a browser instance => : ', err);    }    return browser;  }    module.exports = {    startBrowser,  };  

index.js

const browserObject = require("./browser");  const scraperController = require("./pageController");    //Start the browser and create a browser instance  let browserInstance = browserObject.startBrowser();    // Pass the browser instance to the scraper controller  scraperController(browserInstance);  

pageController.js

const pageScraper = require('./pageScraper');  async function scrapeAll(browserInstance) {    let browser;    try {      browser = await browserInstance;      await pageScraper.scraper(browser);      }    catch (err) {      console.log("Could not resolve the browser instance => ", err);    }  }    module.exports = (browserInstance) => scrapeAll(browserInstance)  

pageScraper.js

const scraper = {      url: 'https://finance.yahoo.com/quote/TSLA/',      async scraper(browser) {          let page = await browser.newPage()            await page.goto(this.url);            console.log("page loaded");          for(var k = 1; k < 2000; k++){              var element = await page.waitForXPath("/html/body/div[1]/div/div/div[1]/div/div[2]/div/div/div[5]/div/div/div/div[3]/div[1]/div[1]/fin-streamer[1]")              var price = await page.evaluate(element => element.textContent, element);              console.log(price);              await page.waitForTimeout(1000);              let demo = document.getElementById("demo")              let displayPrice = "";              displayPrice = "<p>" + price + "</p>"              demo.innerHTML = displayPrice;            }                    await browser.close();      },  };    module.exports = scraper;  

...and package.json

{    "name": "wspuppeteer",    "version": "1.0.0",    "main": "index.js",    "scripts": {      "test": "echo \"Error: no test specified\" && exit 1"    },    "keywords": [],    "author": "",    "license": "ISC",    "dependencies": {      "babel": "^6.23.0",      "puppeteer": "^13.5.1"    },    "devDependencies": {      "@babel/core": "^7.17.8",      "webpack": "^5.70.0"    },    "description": ""  }  

What's causing the problem?

Canvas - Zooming in and out in exactly on the mouse pointer using the mouse wheel - Check codepen example

Posted: 31 Mar 2022 12:55 AM PDT

I just want to be able to zoom IN and OUT exactly on the mouse cursor using the mouse wheel. It should work as it is implemented in the google maps!

I have made an example on codepen to highlight my problem. Please, test it to see the problem. Just go with the mouse pointer to the left eye in the image. Zoom OUT a lot, then move the mouse pointer to the right eye and zoom IN again. You will see that it is not zooming exactly where the mouse position is.

The problem is that I am using the ctx.scale for scaling the image and ctx.translate to make the canvas to comeback to the original state. It is a really fast solution but it is not working so precisely. Could someone help me to solve this problem?

Goal: To be able to zoom OUT and IN in different points at the image, exactly as is beeing done by google maps using the mouse wheel.

Below it is the link of my code example to help to highlight the problem. Any solution will be very appreciate!

[https://codepen.io/MKTechStation/pen/abEyBJm?editors=1111][1]

Thank you very much in advance!

Making a drawn rectangle disappear for pygame

Posted: 31 Mar 2022 12:54 AM PDT

I am only quite new to Python only been working on the Introduction Netacad course for about 4 weeks now and I am having trouble with an lab exercise given to me by my lecturer.

Using a prebuilt pygame file it asks to add in lines of code to add left and right movement upon left and right keydown evens, up and down, and increase speed and decrease for which ive already completed. I am having trouble with the final task which asks:

Add a feature to make player1 sprite visible/invisible when the space bar is pressed.

So i figure this must just be another keydown event/listener but what exactly is the if statement outcome to make my already drawn rectangle sprite disappear and reappear.

This is my code below and sorry if i havent been clear with this im quite new to this language and only ever done C# intro before.

import pygame  # accesses pygame files  import sys  # to communicate with windows    # game setup ################ only runs once  pygame.init()  # starts the game engine  clock = pygame.time.Clock()  # creates clock to limit frames per second  FPS = 60  # sets max speed of main loop  SCREENSIZE = SCREENWIDTH, SCREENHEIGHT = 1000, 800  # sets size of screen/window  screen = pygame.display.set_mode(SCREENSIZE)  # creates window and game screen  # set variables for colors RGB (0-255)  white = (255, 255, 255)  black = (0, 0, 0)  red = (255, 0, 0)  yellow = (255, 255, 0)  green = (0, 255, 0)    gameState = "running"  # controls which state the games is in  player1XPos = 100 #Variable for x axes position of player 1  player1YPos = 100 #Variable for Y axis position  player1Direction = ""  player1Speed = 5  player1Visible  # game loop #################### runs 60 times a second!  # your code starts here ##############################  while gameState != "exit":  # game loop - note:  everything in the mainloop is indented one tab      for event in pygame.event.get():  # get user interaction events          if event.type == pygame.QUIT:  # tests if window's X (close) has been clicked              gameState = "exit"  # causes exit of game loop          if event.type == pygame.KEYDOWN:              if event.key == pygame.K_LEFT:                  #Decreases playerYPos -5 on the X axis                  player1Direction = "left"              elif event.key == pygame.K_RIGHT:                  #Inrceases playerYPos +5 on the Y Axis                  player1Direction = "right"              elif event.key == pygame.K_UP:                  #player1XPos Decreases playerxPos -5 on the X axis                  player1Direction = "up"              elif event.key == pygame.K_DOWN:                  #player1YPos Inrceases playeryPos +5 on the Y axis                  player1Direction = "down"              elif event.key == pygame.K_w:                  player1Speed= player1Speed / 2                  #Decrease movement speed player1Speed of movement              elif event.key == pygame.K_q:                  player1Speed= player1Speed * 2                  #Increase movement speed player1Speed              elif event.key == pygame.K_SPACE:                                                                                    # Player 1 Event handler code now...      if player1Direction =="up":          player1YPos = player1YPos - player1Speed          #Increases the player1 rectangle up on the Y axis      elif player1Direction =="down":          player1YPos = player1YPos + player1Speed          #Decreases the player1 rectangle on Y Axis      if player1Direction =="left":          player1XPos = player1XPos - player1Speed          #Moves the player1Pos to the left by decreasing X Pos by the value of player1Speed          #which is 5      elif player1Direction =="right":          player1XPos = player1XPos + player1Speed          #Moves player1Pos rectangle to the right by increasing player1XPos X axis position          #by the value of player1Speed                        screen.fill(black)      player1 = pygame.draw.rect(screen, red, (player1XPos, player1YPos, 80, 80))                    # your code ends here ###############################      pygame.display.flip()  # transfers build screen to human visable screen      clock.tick(FPS)  # limits game to frame per second, FPS value    # out of game loop ###############  print("The game has closed")  # notifies user the game has ended  pygame.quit()   # stops the game engine  sys.exit()  # close operating system window  

preparing cursor in mysql but not working,

Posted: 31 Mar 2022 12:54 AM PDT

Kindly check the below-mentioned command which i used to prepare the cursor in MySQL but getting an error. Kindly check and let me know where I am wrong and what needs to rectify.

delimiter &&    create procedure cursor_table()    begin    declare firstname varchar(100);    declare cl int default 0;    Declare cursor_2 cursor for select s_fname from student_datasets limit 3;    open cursor_2;    repeat    fetch cursor_2 into firstname;    set cl=cl+1;    until cl=5    end repeat;    select firstname;    close cursor_2;    end &&  

getting error as 1064

Kindly help for same.

i am a beginner in mysql and trying to prepare cursor but not working and getting error .Kindly help.

Flower Framework is not showing federated loss

Posted: 31 Mar 2022 12:55 AM PDT

  1. I am trying to use federated learning framework flower with TensorFlow. My code seems to compile fine but It's not showing federated loss and accuracy. What am I doing wrong?

ServerSide Code :

import flwr as fl  import sys  import numpy as np    class SaveModelStrategy(fl.server.strategy.FedAvg):      def aggregate_fit(          self,          rnd,          results,          failures      ):          aggregated_weights = super().aggregate_fit(rnd, results, failures)          """if aggregated_weights is not None:              # Save aggregated_weights              print(f"Saving round {rnd} aggregated_weights...")              np.savez(f"round-{rnd}-weights.npz", *aggregated_weights)"""          return aggregated_weights    # Create strategy and run server  strategy = SaveModelStrategy()    # Start Flower server for three rounds of federated learning  fl.server.start_server(          server_address = 'localhost:'+str(sys.argv[1]),          #server_address = "[::]:8080" ,          config={"num_rounds": 2} ,          grpc_max_message_length = 1024*1024*1024,          strategy = strategy  )

Server Side: enter image description here

Do we have any other methods about regular expression to match a string by another string?

Posted: 31 Mar 2022 12:54 AM PDT

I met a demand about regular expression. There are two string,one is tags = "(kg|t|KG|T)", anoher is s = "the weight of motor123One and motor567One is 35kg, but there isn't 2t." Now I need match numbers from s by regular expression ,but numbers cannot follow with words from tags, in other word, the output of s should is 123 and 567, not including 35 and 2, becaouse kg and t including tags. I had a method as follows, however it need three regular expression, I hope get a method which use regular expression.

there my methods: public static void Regualr(String targs,String s){ targs = targs.replaceAll("\(","\("").replaceAll("\|",""|"").replaceAll("\)",""\)"); Pattern p1 = Pattern.compile(""(.*?)""); Pattern p2 = Pattern.compile("[0-9]+"); Matcher m = p1.matcher(targs); while (m.find()){ Pattern p3 = Pattern.compile("[0-9]+"+m.group(1)); Matcher m1 = p3.matcher(s); while (m1.find()){ s = s.replaceAll(m1.group(),""); } } Matcher result = p2.matcher(s); while (result.find()){ System.out.println(result.group()); } }

public static void main(String[]args){      String tags = "(kg|t|KG|T)",s = "the weight of motor123One and motor567One is 35kg, but there isn't 2t.";     Regualr(tags,s);  }  

the output as follow: enter image description here

How to solve the self-crash problem of running multiple pyqt or pyqtgraph drawing components?

Posted: 31 Mar 2022 12:55 AM PDT

enter image description here

I designed the interface, and the custom component tried to output multiple drawing components, and the program crashed after a while.

The program probably consists of the following:ble. Py reads the bluetooth values temporarily holding the EMG array. main_plot.py instantiates the Show_EMG plotting class and outputs the Show_EMG plotting class reading the Bluetooth values of ble.PY

The program crashed itself without reporting any errors, I tried to output errors at different terminals.

ERROR MESSAGE: enter image description here

enter image description here

CMD:

enter image description here

pyqtgraph Component Code(Show_EMG.py):

import ble  from pyqtgraph import PlotWidget  import pyqtgraph as pg  import numpy as np  from PyQt5 import QtCore    class Plot_Show(object):      '''      Form,y,x,data,length = 1800, width = 250, high = 120, text = "sEMG Voltage"      '''      def __init__(self,Form,y,x,data,text=""):          # length = 1800, width = 250, high = 120, text = "sEMG Voltage"          self.Form=Form          self.y=y          self.x=x          self.data=ble.EMG[data]          self.length=1800          if(text==""):              self.test="sEMG Voltage"          else:              self.text = text          self.graphicsView = PlotWidget(self.Form)          self.initUI()          def initUI(self):            self.graphicsView.setGeometry(QtCore.QRect(self.y, self.x, 250, 120))          self.graphicsView.hideButtons()          self.graphicsView.setObjectName(self.text)              self.graphicsView.setLabel(axis="left",text=self.text)          self.graphicsView.setLabel(axis='bottom',text='Time')          self.graphicsView.setMouseEnabled(x=False,y=False)          self.graphicsView.setAntialiasing(True)          self.graphicsView.setMenuEnabled(False)          self.graphicsView.hideButtons()          self.data1 = np.zeros(self.length)          self.curve1 = self.graphicsView.plot(self.data1)          self.ptr1 = 0            def update1():              global data1, ptr1              self.graphicsView.setRange(xRange=[self.ptr1,self.ptr1+self.length],yRange=[5,550],padding=0)              self.data1[:-1] = self.data1[1:]  # shift data in the array one sample left                self.data1[-1] = self.data                self.ptr1 += 1              self.curve1.setData(self.data1)              self.curve1.setPos(self.ptr1, 0)            self.timer = pg.QtCore.QTimer()          self.timer.timeout.connect(update1)          self.timer.start(10)  

main_plot.py Code:

import ble  import sys    import Show_EMG  from PyQt5 import QtCore, QtWidgets  import threading    class Ui_Form(object):      def __init__(self):          super().__init__()        def setupUi(self, Form,**kwargs):          Form.resize(820, 454)          Form.setObjectName("Form")                    Show_EMG.Plot_Show(Form=Form, y=10, x=10, data=0, text="sEMG2 Voltage")          Show_EMG.Plot_Show(Form=Form, y=10, x=140, data=1, text="sEMG2 Voltage")          Show_EMG.Plot_Show(Form=Form, y=10, x=270, data=2, text="sEMG3 Voltage")          Show_EMG.Plot_Show(Form=Form, y=280, x=10, data=3, text="sEMG4 Voltage")          Show_EMG.Plot_Show(Form=Form, y=280, x=140, data=4, text="sEMG5 Voltage")          Show_EMG.Plot_Show(Form=Form, y=280, x=270, data=5, text="sEMG6 Voltage")          Show_EMG.Plot_Show(Form=Form, y=550, x=10, data=0, text="sEMG7 Voltage")          Show_EMG.Plot_Show(Form=Form, y=550, x=140, data=0, text="sEMG8 Voltage")            self.gridLayoutWidget = QtWidgets.QWidget(Form)          self.gridLayoutWidget.setGeometry(QtCore.QRect(550, 270, 261, 121))          self.gridLayoutWidget.setObjectName("gridLayoutWidget")          self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)          self.gridLayout.setContentsMargins(0, 0, 0, 0)          self.gridLayout.setObjectName("gridLayout")          self.pushButton = QtWidgets.QPushButton(Form)          self.pushButton.setGeometry(QtCore.QRect(370, 410, 75, 23))          self.pushButton.setObjectName("pushButton")            self.retranslateUi(Form)          QtCore.QMetaObject.connectSlotsByName(Form)        def retranslateUi(self, Form):          _translate = QtCore.QCoreApplication.translate          self.pushButton.setText(_translate("Form", "开始记录"))          Form.setWindowTitle(_translate("Form", "Form"))    def main():      app = QtWidgets.QApplication(sys.argv)      Form = QtWidgets.QWidget()      ui = Ui_Form()      ui.setupUi(Form)      Form.show()      sys.exit(app.exec_())    if __name__ == "__main__":      thread_main=threading.Thread(target=main())      thread_main.start()      thread_ble=threading.Thread(target=ble.ble())      thread_ble.start()  

Ble.EMG array default temporarily to:[200. 0. 0. 0. 0. 0.]

More Ble Code detail: https://gist.github.com/allrobot/1547447f313942f278118cb2e569f59f

I tried to add threads in main_plot.py, but the program still crashes itself...

Perhaps can't call custom components?

How can I change the code to solve the self-crash problem?

How can we use multi color icon in android notification icon

Posted: 31 Mar 2022 12:55 AM PDT

I have already tried with transparent background, it's working fine but I need more than 1 color in the notification small icon.

When I am trying to get results find whatever color we use that will change by icon color what we give in our code only transparent color is always transparent.

I have tried custom layout notifications but I got stuck with android 11 some devices work fine but some devices show a grey square icon.

I want a notification icon with multi-color in the status bar and when we expand notifications.

oggma on windows server 2012 R2 cannot create new deployment

Posted: 31 Mar 2022 12:55 AM PDT

When I create new service deployment using oggma 21c on windows server 2012 R2, there is an INS-85037 error, and it says:

Failed to import administrator user. Make sure the user does not already exist

python for loop in column condition

Posted: 31 Mar 2022 12:55 AM PDT

I just want to make a dictionary with the value of cate4 column in dataframe but seems all value in the dictionary are same

the cate_content table is like below

cate4 content
A sentence1
B sentence2
cate_dict = {}  noun_lists = []  for cate in cate_list:    for content in cate_content[cate_content['cate4']==cate].content:      noun_list = nlpy.nouns(content)      for noun in noun_list:        noun_lists.append(noun)    cate_dict[cate] = noun_lists  

Typescript - Create object based on another

Posted: 31 Mar 2022 12:55 AM PDT

I have the following object (this is the service response):

let contentArray = {     "errorMessages":[             ],     "output":[        {           "id":1,           "excecuteDate":"2022-02-04T13:34:20"        },        {           "id":2,           "excecuteDate":"2022-02-04T12:04:20"        },        {           "id":3,           "excecuteDate":"2022-02-01T11:23:34"        },        {           "id":4,           "excecuteDate":"2022-01-14T10:30:54"        },        {           "id":5,           "excecuteDate":"2021-11-03T10:20:43"        }     ]  }  

Based on the previous object I have to create the following:

{     "2021":{        "11-November":{           "03/11/2021":[              "10:20:43"           ]        }     },     "2022":{        "01_January":{           "14/01/2022":[              "10:30:54"           ]        },        "02_February":{           "01/02/2022":[              "11:23:34"           ],           "04/02/2022":[              "12:04:20", "13:34:20"           ]        }     }  }  

To be able to paint something like this on the screen:

enter image description here

I updated the question to be more specific. Based on the above, I have this code:

        let dateExecutionValue: Date;          let i: number = 0;          let tree = {};          while (i < this.contentArray.length) {              dateExecutionValue = new Date(this.contentArray[i].excecuteDate);              let year = dateExecutionValue.getFullYear();              tree[year] = {};              let auxYear = year;              while (auxYear === year && i < this.contentArray.length) {                  let month = dateExecutionValue.getMonth() + 1;                  // here, now under the year property of the object, I want to create another month property (for each month associated with that year)                  i++;              }              }  

How could I do it? thanks,

Deprecation notice: ReactDOM.render is no longer supported in React 18

Posted: 31 Mar 2022 12:55 AM PDT

I get this error every time I create a new React App and I don't know how to fix it:

Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot

I created my react app using: npx create-react-app my-app

Prolog Sorting a List with each position having two elements

Posted: 31 Mar 2022 12:55 AM PDT

I am currently working on Prolog quick sorting.

The quicksort rule in Prolog is:

quick_sort2(List, Sorted) :-      q_sort(List, [], Sorted).    q_sort([], Acc, Acc).  q_sort([H|T], Acc, Sorted) :-     pivoting(H, T, L1, L2),      q_sort(L1, Acc, Sorted1),     q_sort(L2, [H|Sorted1], Sorted).    pivoting(H, [], [], []).  pivoting(H, [X|T], L, [X|G]) :-X =< H, pivoting(H, T, L, G).  pivoting(H, [X|T], [X|L], G) :-X  > H, pivoting(H, T, L, G).  

It sorts lists that look like this: [1,2,5,3,4]

However, my list currently is in this format with each position having 2 elements:

[(18427840,wplabuan), (801267209,johor), (258368353,kelantan), (381775777,kedah), (443783415,sabah), (188532090,melaka), (540920146,wpkualalumpur), (380758940,pulaupinang), (285145365,pahang), (1447204206,selangor), (243650261,negerisembilan), (47633359,perlis), (455013525,perak), (26449297,wpputrajaya), (204709755,terengganu), (498580177,sarawak)]

May I know how should I sort the list above using quicksort?

Thank you.

I want the list with sum and state (sum, state) to be sorted in ascending order according to the sum.

Problems installing cytoolz on Python@3.10

Posted: 31 Mar 2022 12:55 AM PDT

I am trying to install cytoolz in virtualenv:

  1. Python version = 3.10.0
  2. Pip version = 21.3.1

After running pip install cytoolz in the activated virtualenv I am getting the following log:

Collecting cytoolz    Using cached cytoolz-0.11.0.tar.gz (477 kB)    Preparing metadata (setup.py) ... done  Requirement already satisfied: toolz>=0.8.0 in ./env/lib/python3.10/site-packages (from cytoolz) (0.11.1)  Building wheels for collected packages: cytoolz    Building wheel for cytoolz (setup.py) ... error    ERROR: Command errored out with exit status 1:     command: /Users/hristotodorov/Documents/Vyper/env/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/5y/q2vqps3s0jq7nc73z2zgmpmr0000gn/T/pip-install-0ebpvw2k/cytoolz_455f12fc06374667a15ffeeafa952f0f/setup.py'"'"'; __file__='"'"'/private/var/folders/5y/q2vqps3s0jq7nc73z2zgmpmr0000gn/T/pip-install-0ebpvw2k/cytoolz_455f12fc06374667a15ffeeafa952f0f/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/5y/q2vqps3s0jq7nc73z2zgmpmr0000gn/T/pip-wheel-czxvyqb8         cwd: /private/var/folders/5y/q2vqps3s0jq7nc73z2zgmpmr0000gn/T/pip-install-0ebpvw2k/cytoolz_455f12fc06374667a15ffeeafa952f0f/    Complete output (75 lines):    ALERT: Cython not installed.  Building without Cython.    running bdist_wheel    running build    running build_py    creating build    creating build/lib.macosx-10.9-universal2-3.10    creating build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/compatibility.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/utils_test.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/_version.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/__init__.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/_signatures.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz    creating build/lib.macosx-10.9-universal2-3.10/cytoolz/curried    copying cytoolz/curried/operator.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/curried    copying cytoolz/curried/__init__.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/curried    copying cytoolz/curried/exceptions.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/curried    copying cytoolz/itertoolz.pyx -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/dicttoolz.pyx -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/functoolz.pyx -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/recipes.pyx -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/utils.pyx -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/utils.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/__init__.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/recipes.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/functoolz.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/dicttoolz.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/cpython.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz    copying cytoolz/itertoolz.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz    creating build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_none_safe.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_utils.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_curried.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_compatibility.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_embedded_sigs.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_functoolz.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_inspect_args.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_doctests.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_tlz.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_signatures.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/dev_skip_test.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_recipes.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_docstrings.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_dev_skip_test.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_dicttoolz.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_serialization.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_curried_toolzlike.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    copying cytoolz/tests/test_itertoolz.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests    running build_ext    building 'cytoolz.dicttoolz' extension    creating build/temp.macosx-10.9-universal2-3.10    creating build/temp.macosx-10.9-universal2-3.10/cytoolz    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Users/hristotodorov/Documents/Vyper/env/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c cytoolz/dicttoolz.c -o build/temp.macosx-10.9-universal2-3.10/cytoolz/dicttoolz.o    clang -bundle -undefined dynamic_lookup -arch arm64 -arch x86_64 -g build/temp.macosx-10.9-universal2-3.10/cytoolz/dicttoolz.o -o build/lib.macosx-10.9-universal2-3.10/cytoolz/dicttoolz.cpython-310-darwin.so    building 'cytoolz.functoolz' extension    clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Users/hristotodorov/Documents/Vyper/env/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c cytoolz/functoolz.c -o build/temp.macosx-10.9-universal2-3.10/cytoolz/functoolz.o    cytoolz/functoolz.c:23087:19: error: implicit declaration of function '_PyGen_Send' is invalid in C99 [-Werror,-Wimplicit-function-declaration]                ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);                      ^    cytoolz/functoolz.c:23087:17: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]                ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    cytoolz/functoolz.c:23092:19: error: implicit declaration of function '_PyGen_Send' is invalid in C99 [-Werror,-Wimplicit-function-declaration]                ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);                      ^    cytoolz/functoolz.c:23092:17: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]                ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    cytoolz/functoolz.c:23176:19: error: implicit declaration of function '_PyGen_Send' is invalid in C99 [-Werror,-Wimplicit-function-declaration]                ret = _PyGen_Send((PyGenObject*)yf, NULL);                      ^    cytoolz/functoolz.c:23176:17: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]                ret = _PyGen_Send((PyGenObject*)yf, NULL);                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    3 warnings and 3 errors generated.    error: command '/usr/bin/clang' failed with exit code 1    ----------------------------------------    ERROR: Failed building wheel for cytoolz    Running setup.py clean for cytoolz  Failed to build cytoolz  Installing collected packages: cytoolz      Running setup.py install for cytoolz ... error      ERROR: Command errored out with exit status 1:       command: /Users/hristotodorov/Documents/Vyper/env/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/5y/q2vqps3s0jq7nc73z2zgmpmr0000gn/T/pip-install-0ebpvw2k/cytoolz_455f12fc06374667a15ffeeafa952f0f/setup.py'"'"'; __file__='"'"'/private/var/folders/5y/q2vqps3s0jq7nc73z2zgmpmr0000gn/T/pip-install-0ebpvw2k/cytoolz_455f12fc06374667a15ffeeafa952f0f/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/5y/q2vqps3s0jq7nc73z2zgmpmr0000gn/T/pip-record-s_w__7qh/install-record.txt --single-version-externally-managed --compile --install-headers /Users/hristotodorov/Documents/Vyper/env/include/site/python3.10/cytoolz           cwd: /private/var/folders/5y/q2vqps3s0jq7nc73z2zgmpmr0000gn/T/pip-install-0ebpvw2k/cytoolz_455f12fc06374667a15ffeeafa952f0f/      Complete output (77 lines):      ALERT: Cython not installed.  Building without Cython.      running install      /Users/hristotodorov/Documents/Vyper/env/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.        warnings.warn(      running build      running build_py      creating build      creating build/lib.macosx-10.9-universal2-3.10      creating build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/compatibility.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/utils_test.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/_version.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/__init__.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/_signatures.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz      creating build/lib.macosx-10.9-universal2-3.10/cytoolz/curried      copying cytoolz/curried/operator.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/curried      copying cytoolz/curried/__init__.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/curried      copying cytoolz/curried/exceptions.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/curried      copying cytoolz/itertoolz.pyx -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/dicttoolz.pyx -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/functoolz.pyx -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/recipes.pyx -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/utils.pyx -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/utils.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/__init__.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/recipes.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/functoolz.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/dicttoolz.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/cpython.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz      copying cytoolz/itertoolz.pxd -> build/lib.macosx-10.9-universal2-3.10/cytoolz      creating build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_none_safe.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_utils.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_curried.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_compatibility.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_embedded_sigs.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_functoolz.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_inspect_args.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_doctests.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_tlz.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_signatures.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/dev_skip_test.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_recipes.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_docstrings.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_dev_skip_test.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_dicttoolz.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_serialization.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_curried_toolzlike.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      copying cytoolz/tests/test_itertoolz.py -> build/lib.macosx-10.9-universal2-3.10/cytoolz/tests      running build_ext      building 'cytoolz.dicttoolz' extension      creating build/temp.macosx-10.9-universal2-3.10      creating build/temp.macosx-10.9-universal2-3.10/cytoolz      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Users/hristotodorov/Documents/Vyper/env/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c cytoolz/dicttoolz.c -o build/temp.macosx-10.9-universal2-3.10/cytoolz/dicttoolz.o      clang -bundle -undefined dynamic_lookup -arch arm64 -arch x86_64 -g build/temp.macosx-10.9-universal2-3.10/cytoolz/dicttoolz.o -o build/lib.macosx-10.9-universal2-3.10/cytoolz/dicttoolz.cpython-310-darwin.so      building 'cytoolz.functoolz' extension      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/Users/hristotodorov/Documents/Vyper/env/include -I/Library/Frameworks/Python.framework/Versions/3.10/include/python3.10 -c cytoolz/functoolz.c -o build/temp.macosx-10.9-universal2-3.10/cytoolz/functoolz.o      cytoolz/functoolz.c:23087:19: error: implicit declaration of function '_PyGen_Send' is invalid in C99 [-Werror,-Wimplicit-function-declaration]                  ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);                        ^      cytoolz/functoolz.c:23087:17: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]                  ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);                      ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      cytoolz/functoolz.c:23092:19: error: implicit declaration of function '_PyGen_Send' is invalid in C99 [-Werror,-Wimplicit-function-declaration]                  ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);                        ^      cytoolz/functoolz.c:23092:17: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]                  ret = _PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);                      ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      cytoolz/functoolz.c:23176:19: error: implicit declaration of function '_PyGen_Send' is invalid in C99 [-Werror,-Wimplicit-function-declaration]                  ret = _PyGen_Send((PyGenObject*)yf, NULL);                        ^      cytoolz/functoolz.c:23176:17: warning: incompatible integer to pointer conversion assigning to 'PyObject *' (aka 'struct _object *') from 'int' [-Wint-conversion]                  ret = _PyGen_Send((PyGenObject*)yf, NULL);                      ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      3 warnings and 3 errors generated.      error: command '/usr/bin/clang' failed with exit code 1      ----------------------------------------  ERROR: Command errored out with exit status 1: /Users/hristotodorov/Documents/Vyper/env/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/5y/q2vqps3s0jq7nc73z2zgmpmr0000gn/T/pip-install-0ebpvw2k/cytoolz_455f12fc06374667a15ffeeafa952f0f/setup.py'"'"'; __file__='"'"'/private/var/folders/5y/q2vqps3s0jq7nc73z2zgmpmr0000gn/T/pip-install-0ebpvw2k/cytoolz_455f12fc06374667a15ffeeafa952f0f/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/5y/q2vqps3s0jq7nc73z2zgmpmr0000gn/T/pip-record-s_w__7qh/install-record.txt --single-version-externally-managed --compile --install-headers /Users/hristotodorov/Documents/Vyper/env/include/site/python3.10/cytoolz Check the logs for full command output.    

It appears that there is a problem with the installation of the cytoolz package. Running pip install cytoolz produces the same error. How can I fix that?

Edit: As mention bellow in the comments the problem is not in the eth-brownie but in the cytoolz. Here you can find an open issue in Github.

How do you add a CSS style to a HTML file with a python http.server?

Posted: 31 Mar 2022 12:55 AM PDT

I have a simple http server running from python which returns an HTML file as a GET request. The HTMl file just has some input and it is sent correctly but is not styled even though it is linked to a CSS file. Here is the server.py:

from http.server import BaseHTTPRequestHandler, HTTPServer  import time    hostName = "localhost"  serverPort = 8080    class MyServer(BaseHTTPRequestHandler):      def do_GET(self):              self.send_response(200)              self.send_header("Content-type", "text/html")              self.end_headers()              h = open("main.html", "rb")              self.wfile.write(h.read())      def do_POST(s):          if s.path == '/':              s.path = './main.html'    if __name__ == "__main__":      webServer = HTTPServer((hostName, serverPort), MyServer)      print("Server started http://%s:%s" % (hostName, serverPort))        try:          webServer.serve_forever()      except KeyboardInterrupt:          pass        webServer.server_close()      print("Server stopped.")  

main.html is this

<html>    <head>      <link rel="stylesheet" href="./output.css">  </head>    <body>      <h1 class="mx-auto text-center mt-8 px-0 py-8 border border-4 border-solid border-gray-600"          style="width: 700!important;">CHECKBOX INPUT</h1>      <div class="flex h-full mx-auto">          <form action="">              <div class="w-3/4 py-10 px-8">                  <table class="table-auto">                        <thead>                          <tr>                              <th class="py-10 h-4">                                  <div class="mr-64">                                      <input type="checkbox" class="form-checkbox h-8 w-8">                                      <label class="ml-4">test</label>                                  </div>                              </th>                          </tr>                          <tr>                              <th class="py-10 h-4">                                  <div class="mr-64">                                      <input type="checkbox" class="form-checkbox h-8 w-8">                                      <label class="ml-4"></label>                                  </div>                              </th>                          </tr>                          <tr>                              <th class="py-10 h-4">                                  <div class="mr-64">                                      <input type="checkbox" class="form-checkbox h-8 w-8">                                      <label class="ml-4">test</label>                                  </div>                              </th>                          </tr>                          <tr>                              <th class="py-10 h-4">                                  <div class="mr-64">                                      <input type="checkbox" class="form-checkbox h-8 w-8">                                      <label class="ml-4">test</label>                                  </div>                              </th>                          </tr>                          <tr>                              <th class="px-4  py-10 h-4">                                  <div class="mx-auto">                                      <span>TEXT INPUT:</span>                                      <input type="text" class="form-input mt-4">                                      <select>                                          <option value="value1" selected>DROPDOWN</option>                                          <option value="valeu2">Value 2</option>                                          <option value="valeu3">Value 3</option>                                      </select>                                  </div>                                </th>                          </tr>                          <tr>                              <th class="px-4  py-10 h-4">                                  <div class="mx-auto">                                    </div>                                </th>                          </tr>                          <tr>                              <th class="px-4  py-10 h-4">                                  <div class="mx-auto">                                      <input type="submit" value="Submit" class="bg-gray-600 p-4 border-0 border-solid rounded-lg">                                  </div>                                </th>                          </tr>                      </thead>                    </table>              </div>          </form>      </div>  </body>    </html>  

Even though the HTMl file is linked to output.css when I host the server it returns the HTML file without any styling

Thank you in advance

Cannot import name 'WordCloud'

Posted: 31 Mar 2022 12:55 AM PDT

I am using Jupyter Notebook and trying to build a wordcloud. Turns out there are some issues with the pillow package and the internet is full of talks around it. I was geetting the DLL error initially. I tried a lot of different things and not sure which one worked but right now, I am getting the 'cannot import name' error.

Some details from Anaconda Prompt-

>python -m pip --version  pip 18.0 from C:\Users\Kritika.Jalan\Anaconda3\lib\site-packages\pip (python 3.6)    >python -m pip install wordcloud  Requirement already satisfied: wordcloud in c:\users\kritika.jalan\anaconda3\lib\site-packages (1.5.0)  Requirement already satisfied: numpy>=1.6.1 in c:\users\kritika.jalan\anaconda3\lib\site-packages (from wordcloud) (1.15.0)  Requirement already satisfied: pillow in c:\users\kritika.jalan\anaconda3\lib\site-packages (from wordcloud) (4.0.0)  Requirement already satisfied: olefile in c:\users\kritika.jalan\anaconda3\lib\site-packages (from pillow->wordcloud) (0.45.1)  

Details from Jupyter Notebook -

from wordcloud import WordCloud  ImportError: cannot import name 'WordCloud'    import PIL  print(PIL.PILLOW_VERSION)  5.0.0  

What am I doing wrong here?

Can someone walk me through serving gzipped files from Cloudfront via S3 origin?

Posted: 31 Mar 2022 12:54 AM PDT

I've been through quite a few suggestions given on this topic from other posts on Stackoverflow, but I'm still not successfully getting it to work.

The website origin is on S3, it is being served via Cloudfront. Going through the other posts and Amazon docs, I'm seeing suggestions such as:

1) Gzip the necessary files, remove the .gz from the files name, but on uploading, still set the meta to gzip. This isn't working for me. Safari just downloads the gzipped file(s) instead of serving as a webpage.

2) Amazon docs suggest uploading both a gzipped and none-compressed version of the file, but it makes no reference as to how that works. For example, do you link to both style.css and style.css.gz in the sites html? If so, is that not defeating the object of gzipping to speed up the site as it seems two requests would be made instead of one?

Also, when you set the document Cloudfront is meant to retrieve, e.g. index.html, if you have both a gzipped and non-compressed file, which do you set as the document to retrieve? When I set the document as index.html.gz, the browser again just downloads the file.

I'm getting speed ratings in the 70-80% margins, which, fair does could be worse, but it could be better too. I'm not a beginner, but I'm a million miles away from being an expert at this stuff, so I'm hoping I can get a step by step walk through on here. There must be something I'm not getting quite right.

Thanks in advance for any help.

In OpenGL ES 2.0 / GLSL, where do you need precision specifiers?

Posted: 31 Mar 2022 12:54 AM PDT

Does the variable that you're stuffing values into dictate what precision you're working with, to the right of the equals sign?

For example, is there any difference, of meaning, to the precision specifier here:

gl_FragColor = lowp vec4(1);  

Here's another example:

lowp float floaty = 1. * 2.;  floaty = lowp 1. * lowp 2.;  

And if you take some floats, and create a vector or matrix from them, will that vector or matrix take on the precision of the values you stuff it with, or will those values transform into another precision level?

I think optimizing this would best answer the question:

dot(gl_LightSource[0].position.xyz, gl_NormalMatrix * gl_Normal)  

I mean, does it need to go this far, if you want it as fast as possible, or is some of it useless?

lowp dot(lowp gl_LightSource[0].position.xyz, lowp gl_NormalMatrix * lowp gl_Normal)  

I know you can define the default precision for float, and that this supposedly is used for vectors and matrices afterwards. Assume for the purpose of education, that we had defined this previously:

precision highp float;  

No comments:

Post a Comment