Skip to main content

Posts

Add and Remove items mutually between two categorized multi selection pull downs

Looking to have below kind of LHS & RHS drop down list. enter image description here I have two multi selectable pull down list LHS and RHS. Left side pull down is a super set and right one is a subset. The list is categorized too. User should be able to select whole category and add to right pull down list and similarly one should be able to remove whole category from RHS dropdown list too. If user is selecting only Item2 in Category3 and if Category3 is not present in RHS , the Item2 should be added to RHS along with its Category. How can we implement this using javascript or any Jquery libraries ? I tried to implement this using multi selection pull down list. But how to do the same with category too. I was not able to find a good one . Via Active questions tagged javascript - Stack Overflow https://ift.tt/QuL3tNT

Cupy CUDA: How to free/release device memory using cupy python?

In my original GPU code using cupy , I have multiple intermediate functions which do some computation and return the results. As a MWE , I have the code below in which foo() requires the variables gc_gpu and dgc_gpu to compute the final result. After computing the result, I want to release the device memory hold by the variables gc_gpu and dgc_gpu (just like we do in C++ CUDA by calling cudaFree(varName); ). I read the CUPY documentation and tried to use mempool.free_all_blocks() to release the memory. QUESTION: Even after using mempool.free_all_blocks() , the memory is not released (as I verify in the task manager). How can I free the device memory? import cupy as cp def foo(): gc_gpu = cp.zeros((51 * 51 * 8 * 101 * 101), dtype=cp.float64) dgc_gpu = cp.ones((51 * 51 * 8 * 101 * 101), dtype=cp.float64) result = gc_gpu + dgc_gpu # free memory mempool = cp.get_default_memory_pool() mempool.free_all_blocks() new_result = result * 2 return new

TypeError: I am a bozo and can't debug this typeerror [closed]

I am receiving this error while running my code and can't seem to locate where the error is occurring and what to do about it. Also something to note is that the IDE I am using is not telling me where the error is occurring, just that it is occurring. "TypeError: cannot unpack non-iterable NoneType object" Here is my code: import random def roll_dice(): return random.randint(1, 6), random.randint(1, 6) def computer_turn(game_score, goal): turn_score = 0 while turn_score < goal: (d1, d2) = roll_dice() if d1 == 1 and d2 == 1: game_score = 0 turn_score = 0 break elif d1 == 1 or d2 == 1: turn_score = 0 break else: turn_score += d1 + d2 print(f"Computer rolled {d1}, {d2} Turn total {turn_score}") game_score += turn_score return game_score def human_turn(game_score): turn_score = 0 while True: d1, d2 = rol

Getting a pipe reference into a task

I have two classes, Task1 and Task2. Task1 should read from a TCP/IP port and send up a pipe to Task2. Task2 should return the data to Task1 who echoes this to the client. This is just an experiment. Task2 will eventually process the data and send to another piece of hardware across a serial line. Task1 and Task2 should run on separate cores. I cannot see how to get the pipe reference into the tasks. It is not really necessary Task1 be different from the application. Just has to monitor a TCP/IP port and a pipe asynchronously. Task1 import asyncio import os from multiprocessing import Pipe import sys class Task1: def __init__(self, pipe): self.comm_pipe = pipe async def run(self, reader, writer): while True: data = await reader.read(100) if data: self.comm_pipe.send(data) else: break if self.comm_pipe.poll(): data_from_pipe = self.comm_pipe.recv()

AttributeError: type object 'RegisterUserView' has no attribute '_dataDict'

class RegisterUserView(WestwoodDogsView): def init (self, win): self.win = win self.regUser = tk.Toplevel() super(). init (self.regUser) self.regUser.title(C.REGTITLE) self.regUser.geometry("450x600") self.regUser.columnconfigure(0,weight=1) # the main title for our app, and its logo #amended titleFrame = tk.Frame(self.regUser) tk.Label(titleFrame, text=C.REGTITLE, font=("Verdana", 16), fg="blue", bg="yellow").grid(row=0,column=0) titleFrame.grid(row=1, column=0) # The details of the owner #amended userDetails = ttk.LabelFrame(self.regUser, text="New User Details") userDetails.grid(row=2) rowNum=0 self.userData = dict() for key, details in RegisterUserView._dataDict.items(): print(f"Key is:{key} Details are:{details}") if "text" in details: ttk.Label(userDetails, text=details["text"]).grid( row=rowNum, column=0, padx=5, pady=3,sticky=(tk.E))

Nuxt 3/Vue 3 Reactivity issue, while rendering component in v-for loop

Hey community :) I have a reactivity issue (I think it is about reactivity). Description I have FileInput.vue component. With that component I upload files to project. When the new image is added, the new field is pushing to the form.allImages reactive array: @add="addImageField" addImageField function: const addImageField = (): void => { form.allImages.push({ filename: '' }); }; Reactive data: import type { Images } from '@/types/images.d'; interface Work { allImages: Images[]; } const form: Work = reactive({ allImages: [{ filename: '' }], }); Problem description When I add 2 images and then try to delete the first one using: const deleteImageField = (index: number): void => { form.allImages.splice(index, 1); }; the first block is removing correctly and the second comes up to its place (it is correct), but now the second image block need to be empty(with clear value to be able to add image to that). The value of the secon

Iterating through child elements in puppeteer returns undefined

I'm a beginner with puppeteer and sorry if my question sounds dumb or I missed something. But when I try iterating through the parents node children elements and trying to get its innerText (that does exist) it returns undefined? let Atsiskaitymai = await page.$$("#slenkanti_dalis > table > tbody > tr") for (atsiskaitymas1 of Atsiskaitymai) { let s = await atsiskaitymas1.evaluate(x => Object.values(x.children)) for (let i of s) { console.log(i.innerText); } //returns undefined Thank you for anyone's help. Tried to do: i.evaluate(x => x.innertext) i.getAttribute('innerText') Via Active questions tagged javascript - Stack Overflow https://ift.tt/vnsRy1B