Posts by Woss • 73,416 points
1,476 posts
-
7
votes4
answers1249
viewsA: What is the <canvas> tag for?
The element canvas allows the developer to create images via code. In the case of a web page, the canvas is controlled with Javascript. It is not limited to geometric shapes, you can insert images,…
-
6
votes8
answers955
viewsA: split/regex only on the first vertical bar "|"
Using indexOf to find the first occurrence of the character and split the text, slice, in this position: const text = "João|||23anos|"; let firstMatch = text.indexOf('|'); let parts = [text.slice(0,…
-
14
votes3
answers329
viewsA: What are "code units"?
The word unity derives from the Latin term Unites and designates the quality of what is unique or indivisible. Has as meaning what is considered individually and not plural. The physical limits of a…
-
1
votes3
answers128
viewsA: how to paint an expired date with css
You are using Angular, so use it to implement the necessary logic. You said you have a column that has Yes/No value indicating if the date is expired, so you just add a CSS class to the element that…
-
13
votes1
answer515
viewsQ: Is scripting language always built on another language?
I was reading more about what characterizes a language of script. Namely: What is a scripting language? And the question itself quotes the languages I know of script PHP, Python and Ruby, possibly…
-
10
votes4
answers6112
viewsA: VHDL is a programming language?
VHDL VHDL stands for VHSIC Hardware Description Language, where VHSIC stands for Very High Speed Integrated Circuits; that is, in a free translation, it means description language of hardware for…
-
19
votes4
answers6112
viewsQ: VHDL is a programming language?
VHDL is a language very present in books dealing with logic circuits, but little is spoken of it in other contexts. There is not even a tag vhdl no Stack Overflow em Português. Então: VHDL is a…
-
2
votes2
answers307
viewsA: How to email php checkbox results?
Basically, the value of $_POST["X"] will only exist if the field X have a value on the form. In the case of checkbox, there will only be value if you select it and therefore if you do not select all…
-
0
votes2
answers70
viewsA: Parse feed in Python
If I understand what you need, you will not need third-party libraries (as I think the feedparser is). Python natively has a library to work with XML. See: import xml.etree.ElementTree # Elemento…
-
2
votes1
answer956
viewsA: How to join arrays with repeated keys?
If the keys are necessarily numerical, it is possible to do as follows: function uniqKeys($arr1, $arr2) { foreach($arr2 as $key => $value) { $arr1[$key] = array_key_exists($key, $arr1) ?…
-
4
votes3
answers477
viewsA: Json filter help with jQuery
Consider the following data: const json = { "aPesquisa":[ { "dsObservacao":null, "trecho":[ { "sqTrecho":1, "voo":[ { "dtPartida":"20170620 11:20", "dtChegada":"20170620 16:40" } ] }, {…
-
2
votes1
answer186
viewsA: Create alias for columns of a table in Laravel
Easier than that, you can, in your Model, utilise accessor and mutator to define the shortcut. See the example: <?php namespace App; use Illuminate\Database\Eloquent\Model; class Questao extends…
-
1
votes2
answers165
viewsA: Order of execution of unit tests
The problem is in the method tearDown: public function tearDown() { $this->conn->query("truncate table usuario"); } This method is always executed after each test, whether valid or failed.…
-
2
votes1
answer17
viewsA: How to iterate for objects with indeterminate nesting
If you don’t need to know which nodes are part of the bigger business, just do: public function parentLevel () { $level = 0; if ($this->hasChildren()) { $childrenLevels = [];…
-
1
votes3
answers651
viewsA: sessionStorage with expiry time
An initial reading that is interesting: Differences between localStorage Vs sessionStorage? If you want to persist the value between page sessions, you should use localStorage. From what I read,…
-
2
votes4
answers2467
viewsA: Algorithm for calculating verifier digit
Python In Python, you can do it as follows: code = "55480" def get_divg (code): code = map(int, code) weights = [6, 5, 4, 3, 2] return sum(w * c for w, c in zip(weights, code)) % 7…
-
5
votes2
answers296
viewsA: Logic operations in Python 2.7
The operator and treats your operands as boolean. That is, when you do: 5 and 6 The Python interpreter will do the cast from operands to bool and then check the result. Something like bool(5) and…
-
1
votes4
answers7700
viewsA: Sort a multidimensional array by a column, keeping the same lines of the array
A possible solution is to group the values two by two before sorting: $arr = array_map(null, $arr["sites"], $arr["IPs"]); Sort according to zero index, referring to column sites: usort($arr,…
-
0
votes2
answers138
viewsA: take array time with jQuery?
An alternative, using the Array.prototype.filter, would be: function fhora (horamin, horamax) { return ["11:20", "04:40", "22:30", "07:00", "23:45"].filter(hora => hora >= horamin &&…
-
1
votes1
answer120
viewsA: Error entering data into database with Jquery and Ajax
This behavior happens when you set the expected return to JSON in: dataType : "json" however the server does not return a valid JSON. This way, jQuery, when analyzing the return, considers that…
-
2
votes1
answer107
viewsA: Strange return when calling a function
To make a call from a function, you must put the name of the function, followed by parentheses. If the function has arguments, the values of these should be specified among the (). In your case, you…
-
0
votes1
answer81
viewsA: Angular function 2 similar to Toggle Jquery
Why not use the simple, only with HTML 5? <details> <summary>Em que site estou?</summary> <p>Está no Stack Overflow em Português</p> </details>…
-
0
votes4
answers3032
viewsA: Take part of the html content stored in a variable
The best way to treat HTML with PHP is to use the class DOMDocument: $string = ' <div id="central"> <p>O Primeiro conteudo</p> <h1>O Primeiro n sei oq</h1>…
-
4
votes3
answers82
viewsA: Does anyone know how to do this character in HTML? ( photo below )
You can produce this result only by using CSS rotating an element and working with its edges. This would avoid you having to insert one more font into your project just to use a character. .circle {…
-
20
votes5
answers1202
viewsA: How to perform a task at a precise time in time?
Python In Python there is the package sched which can be used to schedule tasks at certain points of time. See the example: import sched, time, threading, sys trigger = time.mktime((2017, 6, 14, 21,…
-
4
votes4
answers730
viewsA: Hover CSS affect another element
With CSS it is possible yes, but you will need to remove the styling inline element, this is because the style defined in the attribute style has higher priority than styles defined in the CSS,…
-
4
votes1
answer78
viewsA: I need to use an array that’s in one code in another!
To import an object from a module, simply use the import or from ... import. In this case, in the file impressao.py, just do: from jogo import matriz #função de impressão def impressao(): print("…
-
1
votes1
answer666
viewsA: Word processing in csv file
Basically you need to fix the indentations of your code. See an example already using the CSV writing process: import csv # Abre o arquivo de saída para escrita: with open("data.csv", 'r') as…
-
2
votes2
answers844
viewsA: How to separate tags from a variable in PHP array
As commented, the best way to treat HTML text in PHP is to use the class DOMDocument. You can load an HTML page into an object DOMDocument as follows: $dom = new DOMDocument();…
-
23
votes1
answer294
viewsQ: Will-change CSS property: when to use?
According to the W3C specification, the property will-change is intended to inform the browser which CSS properties will be modified so that it can perform optimizations on the elements in question.…
-
47
votes3
answers1078
viewsQ: What is the impact of changing the default behavior of an HTML element?
Recently there was a question here on Stack Overflow about changing the default behavior of checkbox to act on the page as a radio, that is, when selecting an item, the others should be unchecked,…
-
11
votes2
answers210
viewsA: What is the automatically created "o" element between my Buttons in HTML?
As commented, this is a Firefox debug tool that displays white spaces between elements that have display: inline by default, since spaces between these elements are treated by browsers as spacing.…
-
1
votes2
answers68
viewsA: Find term and capture text immediately or after space
I believe it is simpler to use the function preg_match, why the goal is to get an excerpt from the text and not replace it. Semantic code. if (preg_match("/(Apelido\:?)(\s+)(.*)/", $test, $matches))…
-
1
votes1
answer35
viewsA: I can’t save form data
I believe your form is with some errors. <form action="add.php" method="post"> <hr /> <div class="row"> <div class="form-group col-md-7"> <label…
-
0
votes1
answer8422
viewsA: How to insert data into a Mysql B.D with PHP
Considering this part of your code: $nome = $_POST['nome']; $idade = $_POST['idade']; $email = $_POST['email']; $senha = $_POST['senha']; $peso = $_POST['peso']; $altura = $_POST['altura']; $imc =…
-
0
votes1
answer1265
viewsA: visibility:Visible in div javascript
As stated in the comments, for you to change an element style property, just do: document.getElementById('cnpj_erro').style.visibility = "visible"; Take the example: var visible = false; function…
javascriptanswered Woss 73,416 -
3
votes3
answers3142
viewsA: Select Sum in table with PHP/Mysql
Let’s assume that your table has the following structure: create table quantidades ( `id` int not null auto_increment, `data` date, `hora` time, `quantidade` int, primary key (id) ); Considering…
-
3
votes1
answer32
viewsA: How to remove all strings from a string
Just use expressions with the function preg_match_all: The first parameter of the function will be the regular expression: /<b>.*?<\/b>/; The second parameter will be the text from which…
-
2
votes1
answer218
viewsA: Bringing pre-selected radio button option via Cakephp
In accordance with the documentation, just set the value of the attribute value to configure which element will be selected when the form is rendered. Follow the documentation excerpt: 'value' -…
-
2
votes1
answer938
viewsA: Use setlocale for date only
Following the commenting of Leandro Godoy Rosa, according to documentation, there is: LC_ALL for all of the Below LC_COLLATE for string comparison, see strcoll() LC_CTYPE for Character…
-
7
votes1
answer896
viewsA: Type set in Python is ordered?
You’re confusing the terms unordered and sorted. Maniero’s question explains very well each term: What is the difference between ordered, unordered and Sorted? For more details about what is and…
-
1
votes1
answer75
viewsA: Complete other fields
For the answer, I will only consider HTML and Javascript code, assuming that your PHP code works as expected. We will also assume that the loop PHP generates the following HTML snippet for select:…
-
0
votes1
answer65
viewsA: How do I compare the property of an object with a string?
I think what you need is the function property_exists. She returns true if a class or object has a certain property and false otherwise. class Alunos{ public $nome; } $aluno= new Alunos();…
-
7
votes6
answers49406
viewsA: how to search for an element in a list that is inside another list?
I didn’t go through the other answers in depth, but I was a little surprised by the amount of code for a simple task. So I propose here another solution: def search (lista, valor): return…
-
1
votes2
answers298
viewsA: Error installing Slim framework
As discussed in this question in Soen and in this Issue in the official Composer repository, the error is generated due to an incompatibility generated in Windows when the environment variable…
-
2
votes2
answers21
viewsA: How to preg_mach_all in different lines?
If the text has only data from a movie, you can use the function preg_match: if (preg_match("/\((?P<qtd>\d+) eps\)/", $data, $matches)) { echo "O filme possui ", $matches["qtd"], "…
-
3
votes3
answers1394
viewsA: Several different carousel with owlCarousel
As I said in the comments, just insert a id single for each carousel and use it as selector. Note that the id must be in the carousel element, that is, the same element as the class .owl-carousel.…
-
3
votes3
answers253
viewsA: Separate zero from dates
Convert the return to the whole type: $mesAtual = (int) date("m"); In this way, var_dump will result in: int(6) If you prefer, you can use the function intval $mesAtual = intval(date("m")); This…
-
4
votes1
answer3699
viewsA: How the Insert would look in a table that only has a foreign key
If the user registers from an email, it would look something like: INSERT INTO user (id_user, nome, email, senha) VALUES (DEFAULT, "Fulano", "[email protected]", "1234"); INSERT INTO user_controller…
-
8
votes3
answers4863
viewsA: Install with PIP through the Resets.txt file inside Virtualenv?
Starting the environment with dependencies In short, to create an isolated environment to work with a project with the dependencies defined, just follow the steps: Creating the new environment:…