Posts by fernandosavio • 9,013 points
290 posts
-
1
votes2
answers215
viewsA: "Leak" text behind <th> using Sticky CSS position
The solution I found was to create a box-shadow in my thead with the same color as the bottom of the page, so the text is hidden "underneath" the box-shadow creating the effect I want. As mentioned…
-
3
votes1
answer122
viewsQ: Need to use @classmethod in __new__
I was reading about __new__ in the Python documentation and after search here on the site I saw some examples of implementation and noticed that the signature of the method is: def __new__(cls,…
-
1
votes2
answers1430
viewsA: Insert variable in regular expression
Supposing block is a string, the method String.prototype.replace() takes as first parameter a regex OR a string. If the first parameter is a string, the first occurrence of the received substring is…
-
3
votes1
answer33
viewsA: Concatenate two 2D arrays in parallel
You can use the function zip to iterate over the two lists and then concatenate the first element of each sublist. lista_1 = [['a'],['b'],['c']] lista_2 = [['A'],['B'],['C']] concat =…
-
0
votes2
answers179
viewsA: Skip line in XML with Python
If you take a look in that question from Soen will know many interesting answers. I will leave here a brief summary of some responses and a python function to indent your XML if it is not possible…
-
3
votes2
answers306
viewsA: Print only palindromic words
As you are training Python I will post my answer to contribute to your studies. Negative rates The first observation I have is that in your role palindromo you "slice" the string in the following…
-
0
votes1
answer157
viewsA: Django: "Import: cannot import name on_commit"
If you read the documentation of django.db.transaction.on_commit you will see that functionality has only been added in Django 1.9. Remember to check if you are seeing the correct documentation, in…
-
2
votes2
answers3082
viewsA: Python data entry with multiple lines
The function input() always returns a string, to work with other types of data we need to manipulate this string, so let’s go by parts. Receive multiple values We can solve this problem with…
-
3
votes1
answer1114
viewsA: How to get the full size of the scroll?
I turned the comment into a response, so I can post an example. Like scrollTop marks the position of the top of the viewport, will never reach 100%. For your calculation to work just adjust its…
-
1
votes1
answer269
viewsA: My dynamical form in Vue does not work
The detection of changes in Objects and Arrays in Vue.js is limited to the creation moment of the component instance. Vue.js cannot recognize the addition or removal of new properties in objects,…
vue.jsanswered fernandosavio 9,013 -
2
votes1
answer438
viewsA: vuejs - v-bind in pseudo css element
It makes no sense that you want to modify CSS with Vue. It makes more sense to get your CSS ready for the change and make Vue change the "state" of its component. Example: Let’s say you want the…
-
0
votes1
answer24
viewsA: Help Request with VUE JS Variable
You can create a computed Property that is mounted based on the value of data.categoria_selecionada. Something like: new Vue({ el: '#app', data: () => ({ categorias: { 1: 'Categoria 1', 2:…
-
3
votes2
answers647
viewsA: Calculate how many times the values are repeated inside a dictionary KEY - PYTHON
To perform a count of code_client of your records using python you can use: the class collections.Counter a common dictionary the class collections.default_dict ...some other solution I don’t…
-
1
votes3
answers70
viewsA: When opening a div hide the div anteiror
You can make a accordion only with CSS using: Radionbuttons the CSS selector Adjacent Siblings the pseudo CSS class :checked Explanation By definition a Radionbutton is part of a group and only one…
-
2
votes1
answer76
viewsA: Function does not return values
I’ll try to recreate that function based on what you said in: The function must generate and return a randomly generated vector with defined size from a selection made on the page where the user…
-
2
votes2
answers821
viewsA: CPF Mask | CNPJ. when loading
Checking out the documentation you will see that the plugin can receive a function as argument. Also checking the code on Github you will see that the parameters passed to the function are: function…
-
0
votes1
answer88
viewsA: Save files via upload to the folder configured with the stipulated name
1. Image does not go to the folder I created and have given write permission In the documentation of settings.MEDIA_ROOT speaking: Absolute filesystem path to the directory that will hold…
-
2
votes1
answer160
viewsA: Format a number with a certain number of decimals
You can use the constant math.pi together with the function round, which takes as a parameter a number and the number of boxes after the comma. Ex.: from math import pi casas = int(input('Número de…
pythonanswered fernandosavio 9,013 -
1
votes1
answer196
viewsA: Python error with Django on_delete
Felipe, if you check the field documentation Model.ForeignKey you will see that the method signature is: ForeignKey(to, on_delete, **options) And by checking the source code we have the builder: def…
-
1
votes1
answer483
viewsA: Error when transporting excel data to python - date format
In Excel, dates are saved as integers representing how many days have passed since 01/01/1900. If it were that simple it would be enough to create the initial date and add the days with a timedelta:…
-
3
votes2
answers161
viewsA: Help Using List Comprehension/Dictionary
Analyzing the module code tvdb_api that you’re using, the class Show and Season are the daughters of dict where the class values Show are seasons (as seen in method code Show.search()) and the…
-
3
votes1
answer628
viewsA: Doubt about the use of "Row" and "col" classes in Bootstrap
To documentation restricts content within .row, but not within .container: In a grid layout, content must be placed Within Columns and only Columns may be immediate Children of Rows. Translating: In…
-
2
votes3
answers227
viewsA: How to queue for Promises in Javascript?
If the callback of the method Promise.then() return a Promise is made the chaining, so just return to Promise of the new request and continue chaining then(). Simple example: // Retorna um Promise…
-
2
votes4
answers79
viewsA: Problem with a search algorithm on a vector and does not find
Apart from Maniero’s answer, none returns the index where the element was found in the vector as the author of the question expects, so I’ll leave my collaboration using the method list.index()…
-
1
votes3
answers351
viewsA: Invisible button after certain time
You can use the tag events <video> to show and hide other elements on the page. The following example uses the events ended, play and pause to show buttons, where the event ended is only…
-
2
votes4
answers2571
viewsA: Number of vowels in the Python function
To count vowels we will follow the following steps: Read a user-typed string Read letter by string typed by user Check if this letter is a vowel (for educational purposes we will ignore accents) If…
-
1
votes1
answer68
viewsA: Formatting of Python File
If you’re used to using print() can pass your file as argument file for print() that he will print the file instead of the sys.stdout as usual. Ex.: import nltk import nltk.data raw_text =…
-
7
votes1
answer165
viewsA: What is the difference between a Uint8array and a Uint8clampedarray?
TL;DR The difference between both happens when we try to insert an integer value outside allowed range (0 and 255 inclusive). Uint8ClampedArray If it is a negative number, the value will be 0 If it…
javascriptanswered fernandosavio 9,013 -
8
votes1
answer165
viewsQ: What is the difference between a Uint8array and a Uint8clampedarray?
I was reading about Uint8Array and Uint8ClampedArray on MDN, more specifically on the Typedarrays and I came across a table that compares the different types. They’re basically the same, only one is…
javascriptasked fernandosavio 9,013 -
1
votes2
answers483
viewsA: How do I use javascript to make one div visible and hide another?
One <div> making paper buttons is strange and does not help the screen readers nor the semantics of an HTML document. But anyway, the performative solution would be to use CSS to show/hide…
-
3
votes2
answers276
viewsA: Doubts about the import and overall use of Axios in Vuejs
To documentation explains how to use/create plugins, but basically works like this: To use a plugin you need "install" it in its instance using the method Vue.use(). This global method will call the…
-
2
votes3
answers62
viewsA: Function returns value only the first time it is executed
Its function coletar_dados() is a generator, that is, after all the data has been consumed its purpose has been fulfilled. To use it again you need another instance of Generator. In your case just…
python-3.xanswered fernandosavio 9,013 -
1
votes3
answers1077
viewsA: How do I send my form along with another variable via AJAX POST to PHP?
You can use a FormData to serialize the form and enter new data before sending by ajax (example of use with ajax). It is important to check the functionality compatibility if using Formdata (MDN,…
-
0
votes1
answer38
viewsA: Bubblesort in key 3 of a tuple?
You can create your own parameter key that will take the value to make the comparison between values. So instead of doing: if a > b: You do: if key(a) > key(b) Example def bubble_sort(lista,…
python-3.xanswered fernandosavio 9,013 -
2
votes2
answers525
viewsA: Find and Extract a line or words from a source code with Python 3
You can use the library Beautifulsoup to do the Parsing of HTML. Just install with: pip install beautifulsoup4 There in your code you get the HTML as you already did: import urllib.request url =…
pythonanswered fernandosavio 9,013 -
1
votes1
answer61
viewsA: Condition with Jquery: Add attribute when it is not a certain class
You can use the selector :not for that reason: $("#minhaDiv").find(":not(.classe)").show(); Example let $container = $('#container'); $('#impares').on('click', function() {…
jqueryanswered fernandosavio 9,013 -
5
votes3
answers710
viewsA: Take text area values separated by line
Breaking the problem into pieces can be solved as follows: Assuming that a textarea contains the text: abc 123 xyz Break your text into an array using String.split; let linhas =…
javascriptanswered fernandosavio 9,013 -
2
votes2
answers1298
viewsA: How to create a dictionary through a string
I have several files called "plum.json", "banana.json" and "caju.json". What I want to do is take the content of each of these jsons and turn it into a dictionary that will always receive the same…
pythonanswered fernandosavio 9,013 -
9
votes4
answers1730
viewsA: How to maintain a project in 2 repositories?
You can configure how many remotes you need it, and when you push to a repository just choose which one remotes you want to push. Ex.: List configured remote repositories: git remote -v # origin…
gitanswered fernandosavio 9,013 -
3
votes3
answers44
viewsA: jQuery does not format the date field
When your mask function is executed, the input does not yet exist in your document. You need to put your JS at the end of the document or postpone code execution using some event like…
-
8
votes3
answers347
viewsA: Return the oldest person from a list with tuples
You can use the function min() to get the tuple that has the smallest year of birth using the parameter key of function. from operator import itemgetter pessoas = [ ("pedro", 1999, "porto"),…
-
0
votes1
answer85
viewsA: Vue does not print props
Apparently your problem is function context, in your file AppModal.vue you have: reCreate () { Bus.$on('place-modal', function (value) { this.placeModal = value this.id =…
-
3
votes4
answers440
viewsA: How to Fill in the field when the field is empty in PHP?
Using a shortened version of ternary operator is readable, simple and concise: <?php echo trim("") ?: 0; // 0 echo trim("2.5") ?: 0; // "2.5" Explaining, from PHP 5.3 it is possible to omit the…
-
7
votes2
answers96
viewsA: Use of substring for each type of situation
You can use the method String.split() that "breaks" a string into multiple pieces (an array with N elements), just define which will be the separator. Ex: "abc 123 def 456".split(' '); // ['abc',…
-
0
votes2
answers177
viewsA: Replace string with items from an object
You can use a function as the second parameter of String.replace(). She will receive as arguments: match: the married string in Regexp g1, g2, g3, ...: the cadate groups in Regexp, may be 0 to N,…
javascriptanswered fernandosavio 9,013 -
2
votes1
answer357
viewsA: How to execute a synchronous request in a looping
You can use the method Promise.all() to execute all asynchronous requests and, when all results are received, work with them in the same order in which they were called. Promise.all([req_1, req_2,…
-
0
votes2
answers147
viewsA: Get modal element value attribute
Attributes and properties are separate things, when you inspect the HTML you are seeing the attributes of the elements, when you are working with one HMLTInputElement in your javascript you are…
-
2
votes1
answer82
viewsA: Jquery-Querybuilder does not work inside Vuejs
As specified in documentation of the Vue, this.$refs contains references to HTML elements and components registered through the directive ref. So if this.$refs.builder is a reference to an HTML…
-
3
votes2
answers1154
viewsA: Generate line break in Vuejs with v-if
I see two practical solutions to your problem: 1. Medium solution Create a computed Property that provides an array of arrays, where each "child" array has 3 elements only. Ex.: new Vue({ el:…
-
6
votes2
answers313
viewsA: Problems with array "Uncaught Referenceerror: Function is not defined"
You can make a while where the condition to exit the loop is that the array reaches a length of X elements. Inside this while you can use Array.includes and test if the number already exists.…