Skip to main content

Posts

How to use Regex to limit user input to numeric fields, with one allowed decimal and one allowed negative symbol in front

I am trying to only allow numeric values, along with a possible negative symbol at the front of the string, and a single decimal, using Regex in JavaScript. This input value will only allow for a possible 10 digits also. Currently, when a user inputs text, I have this logic that will only allow numbers, negative signs, and decimals. However, I want to limit the number of the negative sign to one, and only allow this at the front of the string. Also, I want to limit the number of decimals to one. input.slice(0, 10).replace(/[^0-9.\-]/, ''); Can anyone please help me figure this out? Via Active questions tagged javascript - Stack Overflow https://ift.tt/tpTR7Uw

JS - Box\inserts planner - solutions and advices

I want to make a frontend (js) app that helps to make blueprints of different boxes\inserts for laser cut. User can create inserts of any form and size and after this it should provide a blueprint (svg) So main problems are: How to render - create HTML boxes or use svg\canvas How to slice rects to have inner 'walls' for inserts How to detect where 'walls' connected to generate connection pattern So in generaly im asking about directions - maybe some useful libraries for render\slice\math such stuff. User can 'plan' something like And after planning app should provide blueprint like Working with pure html and 'div's pretty easy, but slicing it kinda complicated. Via Active questions tagged javascript - Stack Overflow https://ift.tt/tpTR7Uw

Phaser 3 Tetris clone, Game freezes when trying to stack blocks

In the Tetris clone I'm making, I'm only working with single blocks right now and I have been trying to stack blocks in a few rows. Here is the code for the blocks if (this.active == false){ this.cube = Math.floor((Math.random()* 7)); this.testblock = this.physics.add.sprite(608, 32, this.blocks[this.cube]); this.testblock.body.immovable = true; this.testblock.body.allowGravity = false; //this.testblock.body.setGravityY(-100); this.physics.add.collider(this.walls, this.testblock); this.physics.add.collider(this.p1, this.testblock); this.activeBlock = this.testblock; this.active = true; } this.activeBlock.y = this.activeBlock.y + 0.5; if(Phaser.Input.Keyboard.JustDown(this.keyE)){ console.log(this.activeBlock.y); } if(Phaser.Input.Keyboard.JustDown(this.keyA) && this.activeBlock.x != 352) { this.activeBlock.x = this.activeBlock.x - 64; } if(Phaser.Input.Keyboard.JustDown(this.keyD) && this.activeBlock.x != 928) {

I can't modify the interface In vue.js

I have a Laravel project with vue.js, I am new to vue.js, the project is complete, but I have some modifications in some interfaces. When I modify the interface, and I go to see the modifications on the site, it does not appear and does not change anything. I want to know what is the problem and the solution to it?? I deleted the file and re-downloaded it, and it didn't help. I cleaned the config and refreshed the page Via Active questions tagged javascript - Stack Overflow https://ift.tt/Dc31zyL

Unnamed: 0" column impossible to erase

Hello I have a code that filters some rows of a csv and creates a csv without those rows but when I create that csv I get a column called "Unnamed: 0" and it is impossible to delete it. import pandas as pd df = pd.read_csv("table.csv") df.drop(df[df['Stock'].eq('No')].index, inplace=True) df.to_csv('pedro.csv', index=False ) I have tried everything, I have even set index = False but it still comes out. And I have also tried using drop import pandas as pd df2= pd.read_csv("pedro.csv") df2.drop("Unnamed: 0", axis=1) But it still doesn't work because it returns this: Unnamed: 0 Titulo Precio Stock Ultima Vez 0 0 RPi CM4 - 8GB RAM, 32GB MMC, With Wifi (EUR) 120.52 Yes 20-Nov-22 1 1 RPi CM4 - 2GB RAM, No MMC, No Wifi (EUR) 44.40 Yes 20-Nov-22 2 2 RPi CM4 - 1GB RAM, 32GB MMC, No Wifi (EUR) 57.08 Yes 20-Nov-22 3

(Guizero) Writing code that so that when the user clicks on the button a new window will open containg detail from a listbox (not using tkinter)

I am having trouble where I am writing code where I take a csv file and populate it on a listbox, Then I am using another csv file to relate to the item on the first csv. When the user selects a car and pushes the button called "Get Info" under the listbox, a new window will open. That new window will contain detail on the selected item from my first csv file. When the user clicks on the second button called "Last 3 drivers" a new window will open that gives information relating to the first csv file from my second csv file. Here is the full code from guizero import App, ListBox, Text, TextBox, PushButton, Window app = App("Cars", layout='grid') app.height = 350 app.width =350 app.bg = 'gray' text = Text(app, grid =[0,0], text="Buy a Car here!!!!!!\n(Cars are guaranteed to breakdown,no refunds)") text2 = Text(app, grid= [0,70], text="Select the Car to learn more\n information about it") text2.size = '10' listb

Why does python return None in this instance?

I have this python practice question which is to return True if a word is an isogram (word with nonrepeating characters). It is also supposed to return True if the isogram is a blank string. My answer didn't work out. from string import ascii_lowercase def is_isogram(iso): for x in iso: return False if (iso.count(x) > 1) and (x in ascii_lowercase) else True #None While another answered: def is_isogram(word): word = str(word).lower() alphabet_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] for i in word: if word.count(i) > 1 and i in alphabet_list: return False return True #True I'm not sure why the return value is different wi