Posts by fernandosavio • 9,013 points
290 posts
-
2
votes2
answers35
viewsA: centering dynamically
You can use CSS Flex for this. All you have to do is say .pg is a flex container and configure the properties flex-wrap and justify-content. This guide is very practical to use as cheatsheet. .pg {…
-
2
votes4
answers5300
viewsA: How to fix the number of numeric characters in a float?
TL;DR You can do this by calculating the size of the unit part, whether it is negative or not, and then round up the number according to the previous numbers. def num_to_7_char(num): if num == 0:…
-
8
votes3
answers927
viewsA: Remove a part of the URL
You can use regular expressions to isolate part of the string using String.replace(): const URL = "https://teste.teste.pt/sites/teste/Normativo/NormasDeProcedimentos/Documents/Histórico/" const…
-
6
votes2
answers232
viewsA: Abaloada shape with CSS how to do? How to make a Shape in this kind of aredondado format?
There is the CSS property clip-path which you can use to cut unwanted parts from the background of the element. This article from CSS Tricks has some cool examples to understand how property works.…
-
2
votes2
answers184
viewsA: List year in the current year select to 10 years ago in descending order
It’s not easier just to generate years backwards? <?php $anoInicio = intval(date('Y')); for ($i=0; $i < 10; $i++, $anoInicio--) { echo '<option…
phpanswered fernandosavio 9,013 -
5
votes4
answers146
viewsA: Performing functions with and without creating local variables
Just to complement Maniero’s response: You can use the module dis (Disassembler) to check the difference between the generated bytecodes. Ex.: from dis import dis def exemplo_1(x): output = x + 1…
-
3
votes2
answers162
viewsA: Leaving the Jqery foreach
The method Array.forEach is javascript, you must have confused with the $.each jQuery. You can use jQuery: let array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] $.each(array, (i, num) => { console.log(num)…
-
0
votes2
answers407
viewsA: Why does my onclick on an onload not work?
First you’d better use the method Element.addEventListener() to listen to events, the methods onevento are old and allow only one event Handler in the element. Ex.: let elemento =…
javascriptanswered fernandosavio 9,013 -
9
votes2
answers1762
viewsA: Catch current date with Vue
I don’t understand why it can’t be in pure javascript. After all, Vue.JS is also in pure javascript, just use the code in the framework. You can create an array with the name of the months and get…
-
0
votes3
answers1300
viewsA: How to remove item from an array by filtering by value?
Instead of searching for the index of the element with each click, you can use the v-for indexed: <li v-for="(valor, index) in valores" @click="remove(i)"> It gets simpler, faster and more…
-
8
votes2
answers438
viewsA: Conditional VUE array count
TL;DR You can use the method Array.reduce() to return a sum of the items, adding 1 when active is true and 0 otherwise. dados.reduce((acc, {active}) => acc + !!active, 0) Explanation The method…
javascriptanswered fernandosavio 9,013 -
2
votes5
answers459
viewsA: Concatenate id by description into an array in javascript
I will collaborate with an O(n) algorithm instead of O(n 2), using two non-nested loop repeats. The first loop groups the id by country: var grupos = {}; lista.forEach(function(obj) {…
-
2
votes1
answer75
viewsA: How to obtain items that multiple lists have in common
"Items in common" in set theory is called intersection. In python, sets (whose translation is literally "sets") have operators and methods ready for you to use. In this case you can use the method…
-
1
votes4
answers1922
viewsA: How to browse a list using each JQUERY
You don’t need to use jQuery to iterate in your array, you can use the method Array.forEach. let lista = ['a', 'b', 'c']; lista.forEach(function(element, index) { console.log(`lista[${index}] ==…
-
0
votes1
answer201
viewsA: error with password_verify()
You are passing the wrong parameters to your method. Note the signature of your method: private function compararSenha($hash){ return password_verify($this->getSenha(), $hash); } She receives…
-
5
votes2
answers125
viewsA: Array search, with multiple key relations x value
You can use the function array_search to search for values within the array. But if you don’t need to know where the element is, the function in_array serves the purpose. The behavior of comparisons…
phpanswered fernandosavio 9,013 -
5
votes2
answers215
viewsQ: "Leak" text behind <th> using Sticky CSS position
I’m using position: sticky; in the <thead> of a table where I assign a background color to <th>. My intention is that, when scrolling the page, the header remains visible because the…
-
2
votes2
answers548
viewsA: Using two functions in the same Onclick
You can intercept the click event before it reaches the button, run the tests you need, and decide whether to let the event reach the button or not. To do this you will need to understand how events…
-
2
votes2
answers1150
viewsA: Check if a file exists within a Python IF
Note that you are not putting : on the lines of if and of else and also if the path for a folder os.path.exists() will return True and os.remove() will make a mistake. You can test if the file…
-
1
votes1
answer65
viewsA: How to copy a. txt file that updates the name daily - Python
Just use the method date.today() module datetime to pick up the current date and use the date formatting options to correctly create the file name you want. For example: from datetime import date…
-
1
votes2
answers108
viewsA: Loop form on the Laravel
If you check the documentation of <tr> will see the following line: Permitted content: Zero or more <td> and/or <th> Elements; script-supporting Elements (<script> and…
-
2
votes1
answer128
viewsA: problems with (array) object
The problem seems to be in the conversion to array, in the code: $produto[] = (array) $cada If you read the PHP documentation where you talk about arrays, more specifically in the session…
-
3
votes3
answers370
viewsA: How to get the day with two houses in JS
You can also use the method String.padStart() to fill the number with zeros on the left. Its syntax is: minha_string.padStart(tamanho) // ou minha_string.padStart(tamanho, string_de_preenchimento)…
javascriptanswered fernandosavio 9,013 -
0
votes2
answers55
viewsA: Insert only the populated row in the table
I see two possible approaches: Do not send values that are not filled in to the server (using Javascript); Filter incoming data on the server and remove unfilled inputs. Since data should be…
-
3
votes1
answer65
viewsA: Place the information contained in Linha2[0:6] in a ". txt file
Since you want to copy part of one file to another, the steps I would do are: Open a file for reading (open('meu_arquivo', 'r')) Open a file for recording (open('outro_arquivo', 'w')) Read the file…
pythonanswered fernandosavio 9,013 -
2
votes3
answers94
viewsA: List with dynamic size
You can use flexbox to divide the width of the screen equally between the list elements. Just use display: flex; in <ul> and flex-grow in <li>. Here has a good flexbox cheatsheet.…
-
4
votes2
answers28
viewsA: Seleção Elementos
You will use: jQuery.closest() to select the tr closer to the button on the DOM tree jQuery.find() to select the td.descricao jQuery.text() to take the contents of td.descricao Example:…
-
1
votes1
answer68
viewsA: Help to capture change in checkbox field
How you are generating the checkboxes dynamically, when you run $("input[type=checkbox]").on( "click", armazenarCampos) they don’t exist yet. Then you’ll be listening to the event click only of…
jqueryanswered fernandosavio 9,013 -
0
votes5
answers2417
viewsA: How do I get the value of an Hidden input with jquery
If you want to send these inputs to the server there is no need to use JS for this, just assign the names correctly. The server knows that inputs with repeated names are arrays (unless you use PHP…
jqueryanswered fernandosavio 9,013 -
2
votes2
answers413
viewsA: Get text from a select inside a javascript foreach
The id should be unique in a document if you need to use multiple elements with the same id probably what you want is to use classes. I created an example where I use classes to select the input…
javascriptanswered fernandosavio 9,013 -
1
votes3
answers166
viewsA: Disable tab showing all results
To remove the "All" you need: Remove HTML from filters, i.e., remove <li class="active" data-filter="*"><a href="#">todos</a></li> Set the initial filter in the Isotope…
-
1
votes1
answer578
viewsA: Axios GET is not collecting any information
The problem is in the JSON structure, you are not getting the data correctly. Axios requests return an object with response metadata and an attribute data which is the datum of the answer itself.…
-
2
votes1
answer117
viewsA: Put description in image with Hover
Stay tuned to the site you’re using as an example, because the tag <figcaption> should be used exclusively as the first or last child element of a tag figure (and not from a tag <a> as…
-
3
votes2
answers322
viewsA: Animated dropdown with jQuery
You can use the method jQuery.stop() to cancel the animation that is already happening before restarting the new animation. Without the stop, if the user does the hover several times in a row…
-
3
votes2
answers624
viewsA: Text and responsive image
As a complement to Hugo’s response, Bootstrap already has tools to change the property display varying according to the width of the viewport (through the media queries). Are the classes d-*…
-
0
votes1
answer314
viewsA: Django 2.0.9 - Multiselectformfield - Parameter to make not mandatory
Guy, in the documentation there’s no Multiselectfield, so I guess you’re using Django-multiselectfield (it would be nice to specify in the question the lib and the version). Seeing the code, you can…
-
2
votes2
answers51
viewsA: jQuery "contains word" selector does not work as expected
Using the method $.prop() you can pass a function that will be executed for each element. In this function you can use the method $.is() to test if the element matches the selector passed to change…
jqueryanswered fernandosavio 9,013 -
1
votes2
answers3264
viewsA: Convert the timestamp result to the formed Date and Time
The builder of Date can receive a timestamp, then just extract the information you want to a string or the ready methods like the toISOString. Example: let timestamp = 1544380561000; // 09/12/2018…
-
0
votes2
answers476
viewsA: Error with checked property and value in Angular
Checked property does not exist in type 'Htmlelement'. It means that the name that you passed did not return elements of the type radio or checkbox (are the ones that contain the property checked).…
-
7
votes2
answers223
viewsA: How do I concatenate a decimal value?
What you can do is transform $numero and $decimal in a value accepted by the function floatval(). For that just concatenate $numero, a point and $decimal. Example: <?php $numero = "5"; $decimal =…
phpanswered fernandosavio 9,013 -
3
votes1
answer24
viewsA: Mark the day of each week by repeating a number of times
The algorithm is simple, you need: Create an initial date Printar data Adds 1 week Go back to step 2 until repetitions are sufficient Example: <?php $hoje = new DateTime(); $semana = new…
-
3
votes2
answers706
viewsA: I calculate value with Comma with Vue.JS
Like the bfavaretto already mentioned you can swap the comma by dot for JS to do the automatic conversion to Number when subtraction is made. But you could have a function to convert this string to…
-
3
votes3
answers57
viewsA: Map two arrays and delete item not found
The method Array.map() apply a function to an array and return a new array where each element of this new array is the result of the function applied to the elements of the previous array. What you…
-
1
votes1
answer159
viewsA: Laravel array Session overriding
You don’t need to test if the key already exists cart in the session. The method Session::push() will add an item to an array in the session, if that array does not exist it automatically creates.…
-
1
votes2
answers263
viewsA: Clear input with Jquery with more than one class
If you want to select all inputs that nay contains the class noclear, just use the jQuery selector :not() or the method jQuery.not(). let $inputs = $('input:not(.noclear)'); // ou let $inputs =…
-
3
votes3
answers872
viewsA: How to validate if a value is a tuple having a string and an integer?
I’ll start from the premise that you forgot to put the quotes in your strings. Then the correct tuple would be: (('joao', 39), ('paulo', 15), ('andre', 14), ('simao', 21)) From this you need to know…
-
3
votes2
answers897
viewsA: Is there an Excel function that associates letters with numbers (A = 1, B = 2, C = 3 etc.)?
According to this article you can use the functions COLUMN and INDIRECT together to pick the numeric index of a string that represents a column. The function INDIRECT can receive a string…
excelanswered fernandosavio 9,013 -
4
votes5
answers2803
viewsA: How to make CSS a paragraph with Capitular letter (Drop Caps)
Nothing to add regarding the other answers, apart from the use of float: left to have an effect more like the print of the question. p::first-letter { font-size: 4rem; font-weight: bold; float:…
-
7
votes2
answers259
viewsA: Calculation of tenths of a second
As the return of the method Date.getTime() is in milliseconds just you take the rest of the split by 1000 and convert calculated thousandths to tenths. var countDownDate = new Date("Nov 30, 2018…
-
3
votes2
answers2226
viewsA: Switch string to high box and remove blanks
The method str.strip() removes characters from the beginning and the end of a string only. string = " a b ".strip() print(string); # 'a b' Already the method str.replace() takes as first parameter a…