Skip to main content

Posts

How to process asynchronously such a data structure?

I need help, I can't figure out how to process such a data structure asynchronously? markets = { 'AAAA': [ [100, 500, 300], # chunk 1 [101, 501, 301], # chunk 2 [102, 502, 302], # chunk 3 [103, 503, 303], # chunk 4 ], 'BBBB': [ [110, 510, 310], # chunk 1 [111, 511, 311], # chunk 2 [112, 512, 312], # chunk 3 [113, 513, 313], # chunk 4 ], 'CCCC': [ [120, 520, 320], # chunk 1 [121, 521, 321], # chunk 2 [122, 522, 322], # chunk 3 [114, 514, 314], # chunk 4 ], } What is the meaning of the example, I have stores, and I need to update the product data via the API, I need to do this as quickly as possible, but I can't make too many requests to the store. I solved this problem by splitting this task into parts of 3 pieces (numbers symbolize each individual task) and an array of numbers symbolizes a chunk I want to create a coroutine for all ...

timespan + specific time with python schedule package

I want to schedule my Skript ever hour at :45 an run this betwenn the hours of 7 a.m. and 10 p.m. I found the schedule package that seems to meet my requirements but I was unable to combine all criteria. My best to solutions would be to run this in 16 different version like: schedule.every().day.at("07:45").do(Crawlen) schedule.every().day.at("08:45").do(Crawlen) the other option would be: schedule.every().monday.hour(":45").do(Crawlen) but then it would run also throu the night. Am i missing some functions i could use? source https://stackoverflow.com/questions/76443033/timespan-specific-time-with-python-schedule-package

Using python I would like to know how to delete the first occurrence of a character between two strings in a file

For example if I had some file: OPEN( ,a ,b ) CLOSE OPEN( c ) CLOSE OPEN( ,d ,e ,f ) CLOSE I would like to remove the first occurrence of the character ',' following each 'OPEN(' but only if it occurs before the next ') CLOSE' such that the resulting file would look like: OPEN( a ,b ) CLOSE OPEN( c ) CLOSE OPEN( d ,e ,f ) CLOSE Any thoughts on how I should approach? I have tried using regex, but I don't know how to specify conditions. Could some combination of awk & sed be used? attempted regex solution: pattern = r'WITH \(([^)]+),([^)]+)\) AS' replacement = r'WITH (\1\2) AS' sql_content_modified = re.sub(pattern, replacement, sql_content) ended up solving with something like: # Read the SQL file with open(f'{filename}', 'r') as file: content = file.read() content_modified = content.replace('(\n,', '(') content_modified = re.sub('--<([a-z]*.*[A-Z]*)>', '', c...

Subclassing `ndarray` following tutorial yields unexpected results (i.e. partial memory, some attributes are remembers others are lost)

I think I followed the subclassing tutorial correctly. I have a very simple example. It works when I run the code once. When I rerun a cell in a Jupyter notebook, then the class breaks and it "forgets" state (well it remembers the stuff I added, it forgets that transpose I did to numpy array). See code below. Below I implement three simple classes NamedAxis, NamedAxes, and NamedArray (yes I am aware of xarray, this is for my own learning purposes). Mostly it works fine. However, I notice something very frustrating when I rerun flip from copy import deepcopy from dataclasses import dataclass, field from typing import List, Dict, Union, Optional, Any, Callable, TypeVar, Generic, Type, cast, Tuple import numpy as np, pandas as pd @dataclass class NamedAxis: # name of axis name: str # index of axis axis: Optional[int] = None def __str__(self): return f'{self.name}({self.axis})' __repr__ = __str__ def copy(self) -> 'Nam...

Downgrade Python 3.10 to 3.9 in google colab

It looks like there is a compatibility issue with PyTorch and Python 3.10 when I want to use google Colab. I need to use !pip install torch==1.8 torchvision==0.9 but this problem don't let me. I should do Downgrading. I need to get code to downgarde Python version. source https://stackoverflow.com/questions/76442909/downgrade-python-3-10-to-3-9-in-google-colab

MERN stack roadmap easy 2023? [closed]

I need MERN stack roadmap easy 2023 MERN stack roadmap easy 2023? Is MERN stack in demand in 2023? How to learn MERN stack roadmap? How to become a full stack developer in 2023? Is MERN stack tough or easy? Is full-stack developer a good career in 2023? Is MERN stack highly paid? Some questions related to tech used in MERN> What are React Hooks? What are props in React? What are the differences between a Class component and a Functional component? What is call-back hell? Difference between Cassandra and MongoDB What is React Fiber? What are uncontrolled components? How to create props proxy for HOC component? Why is Node.js Single-threaded? How would you define the term I/O? Via Active questions tagged javascript - Stack Overflow https://ift.tt/Zj1UbJy

NodeJS regex returns 0 on string.search()

I'm working on a NodeJS script (launched from the CMD with the node command) getting me some HTML content in a string, in which I need to extract some data between a specific <div> element. I'm having a hard time firguring why this portion of code doesn't give me the desired output. const input = '<div class="some_class">Some data</div><div class="some_other_class">< class="some_other_other_class">...</div></div>' const regex = new RegExp(/<div class="some_class"\>(.*?)<\/div>/g) let obj = { 'tmp': input.search(regex), } console.log(obj) // outputs { tmp: 0} console.log(input.search(/<div class="some_class"\>(.*?)<\/div>/g)) // outputs 0 const x = input.search(/<div class="some_class"\>(.*?)<\/div>/g) console.log(x) // outputs 0 I know this seems a bit of a regular issue here, but I tried passing the Regex with st...