Posts by Giovanni Nunes • 2,638 points
141 posts
-
1
votes2
answers839
viewsA: How to make a Javascript mask for type tel?
Yes, you can do it directly in HTML5 via the parameter pattern and using a regular expression: <input type="text" id="tel" pattern="\([0-9]{2}\) [0-9]{4}-[0-9]{4}"> In this case the browser…
-
2
votes1
answer136
viewsA: Wildfly server
Usually you need to touch the wildfly.conf and edit the JBOSS_OPTS environment variable so that it "listens" to other interfaces; so that it responds at all is something like this: JBOSS_OPTS="-b…
-
1
votes2
answers180
viewsA: Sum of javascript date
There are two approaches to this problem, in the first you consider that there is an exact interval of 30 days for the expiration date of each installment: let dia = 23; let mes = 4-1; // janeiro =…
-
2
votes2
answers555
viewsA: How to use for in Ruby?
The syntax of for in Ruby is: for «variável» in «lista» «comandos» end To make a loop that goes from 0 to 9 (10 repetitions), something equivalent to for(i=0; i<10; i++), you will do: for i in…
-
0
votes2
answers3792
viewsA: Source is not recognized as an internal command
If I’m not mistaken the console of Pycharm executes the Python in interactive mode and not the shell of the operating system. The source is precisely one of the internal commands of the Bash, hence…
pathanswered Giovanni Nunes 2,638 -
1
votes1
answer278
viewsA: Problem consuming JSON with Angularjs
I could not replicate the error message you got with your code but an error Injecting. When I fixed the problem, I was able to read the JSON: <!doctype html> <html> <head> <meta…
-
-2
votes2
answers68
viewsA: Creating Mysql user safely
This will depend on what tasks the user will need to perform in the database. For example, the user of an application will need the basic privileges (select, Insert, update and delete) but in some…
-
4
votes1
answer86
viewsA: Storing past data - Django
You need to create a template to store Spins, something like: class Rodada(models.Model): jogador = models.ForeignKey(Perfil, on_delete=models.CASCADE, related_name='rodadas') rodada =…
-
2
votes1
answer137
viewsA: Syntax error in if and Elif systems
The indentation in the code you posted is wrong because all "cv2." should be starting in the same column as "id". if (id == 1): id = "Tiago" cv2.cv.PutText(cv2.cv.fromarray(img),str(id),…
-
0
votes1
answer357
viewsA: raw_input and python print do not work in functions
You need to call the functions, the most elegant way in Python is to create a main function(): def main(): nivel_escolhido = nivel() jogada(nivel_escolhido) if __name__ == "__main__": main() So your…
pythonanswered Giovanni Nunes 2,638 -
1
votes1
answer340
viewsA: Python : 'int' Object is not iterable Random function
It’s not the reason for the mistake but here it should be: pos = random.randint(0,15) But I think the mistake is here: # ... elif (x[h,E]==1 and x[h,pos]==0): x=[h,pos]=1 break # ... That should be…
-
-1
votes1
answer740
viewsA: Delete table record with foreign key
I believe you must first execute the SET FOREIGN_KEY_CHECKS=0; and then the DELETE FROM ...;. Both with their respective ; since they are separate commands.…
-
0
votes3
answers3080
viewsA: Check the line containing a string inside a TXT file
A way to do it in a slightly more extensive version: #!/usr/bin/env python3 arquivo = 'arquivo.txt' pesquisa = 'batata' achei = False with open(arquivo,'r') as f: linha = 1 for texto in f: if…
-
2
votes2
answers426
viewsA: Lists in PYTHON
Use lista[0] to take the first element, lista[1] to pick up the second and so on. To know the size of a list use the function len(). lista = [1, 2, 3, 4, 5] print(lista[0]) print(lista(1])…
-
1
votes2
answers112
viewsA: Code repetition
Treat the variable $channel as a class attribute and create a specific private method to initialize it with the values that are already repeated inside, something like this: class PhabricatorModel {…
-
0
votes1
answer1006
viewsA: How to run Python scripts with . txt entry in Windows?
I can’t test it here but I believe type entrada.txt | python arquivo.py should work on Windows. If you are using Python in Windows it might be interesting to install the Git for Windows, not by Git…
python-2.7answered Giovanni Nunes 2,638 -
1
votes2
answers346
viewsA: $(Function() does not work
You have noticed that you are loading versions 2.2.3 and 1.10.1 of jQuery? <script src="http://code.jquery.com/jquery-2.2.3.min.js"></script> <script type="text/javascript"…
javascriptanswered Giovanni Nunes 2,638 -
0
votes2
answers953
viewsA: How to use strip() next to a list or tuple in python?
Your code is validating with op_sim, but I believe it is option. Regardless of this you are taking the first character of the answer ("S", "Y" etc) and looking for it inside the tuple ("SIM",…
python-3.xanswered Giovanni Nunes 2,638 -
1
votes2
answers222
viewsA: Format year on Sqlite
Perhaps the best solution is to treat this directly in the programming language, since the strftime() in the Sqlite does not implement all formatting options of strftime() of language C. But if you…
-
1
votes2
answers523
viewsA: File encoding in ASC II
The characters must contain codes ASCII 7-bit standard (from 0 to 127, that is, no UNICODE or other encoding of accents or symbols), at the end of each record/row one you will include the characters…
-
0
votes2
answers78
viewsA: I want to queue numbers. Python 3.6
Serves for numbers, characters and also strings: >>> '4'*2 '44' >>> '4'*10 '4444444444' >>> 'a'*10 'aaaaaaaaaa' >>> 'abc'*3 'abcabcabc' In the case of your code…
python-3.xanswered Giovanni Nunes 2,638 -
1
votes2
answers1669
viewsA: Changing the Python CSV File Delimiter
Use the "delimiter" parameter, for example: import csv # ... with open('arquivo.csv', 'wb') as arquivo: arquivo_csv = csv.writer(arquivo, delimiter=';') arquivo_csv.writerow( ... ) # ...…
-
0
votes1
answer265
viewsA: How to "reset" Python on Ubuntu 16.04 LTS
This installation is in your home directory but apparently you have taken some action with sudo and is the reason for the Pip can’t delete your files. Go to '/home/rafamttz/python2713/' and check…
pythonanswered Giovanni Nunes 2,638 -
1
votes1
answer1310
viewsA: Is there any way to recover the history of all queries executed on a Mysql server?
It’s called general query log and is disabled by default. Enabling it the server will store each operation performed; it is worth reading the documentation on the subject as it is possible to create…
-
1
votes1
answer914
viewsA: Use return of one method in another method of the same class
You could play the output of one method at the entrance of the other but this is not very pretty (like, the information comes out of the object and then goes in). Oh yes, to execute methods when…
-
1
votes1
answer570
viewsA: How do I redirect . htaccess from a subdomain to the main domain?
Create a directory called "folder" in Documentroot where are the files pages of www.dominio.com.br ("/var/www/html", "/opt/site/" etc) and within it create the file ". htaccess" with the following…
-
1
votes1
answer923
viewsA: Select with Laravel foreign key
You need to first define the relationship in the model, for example: <?php class Aluno extends Eloquent { // ... public function cursos(){ return $this->hasMany('Curso'); } ?> This allows…
-
0
votes1
answer523
viewsA: Join data from two tables per foreign key - Rails Activerecord
In the "User" class you used the has_many :comments and/or has_many :profiles to indicate both sides of the relationship? This would allow you to take this information from "User" with: > c =…
-
1
votes3
answers169
viewsA: 2 Arrays in foreach from a form
The foreach() will only work with one array at a time, so it should be one for each. But if both lists have the same number of elements do something using good old for(): <?php // ... for($i=0;…
phpanswered Giovanni Nunes 2,638 -
0
votes1
answer207
viewsA: How do I identify the amount that was repeated and the names repeated?
A tip to help you: divide the problem into parts to facilitate your implementation: You should read up 100 valid names (not empty) This is a loop that will repeat until it reaches a condition; If…
-
0
votes1
answer28
viewsA: Send data to a pdf and email file
Only using HTML you won’t be able to do it so easy (there are Javascript libraries that could take care of this paete) but something simple to implement, but requiring an email client installed and…
-
2
votes2
answers875
viewsA: About rowspan
They serve to indicate that a certain td will expand by a specific number of rows ("rowspan") or columns ("colspan") beyond the space it would already occupy in the table. For example, "colspan=3"…
htmlanswered Giovanni Nunes 2,638 -
1
votes1
answer146
viewsA: Serial Communication and Array Division with Comma
Use the method split() to break the string that you receive by serial and use the return to feed the variables: >>> valor="292.00,2436.00" >>> (v1, v2) = valor.split(",")…
-
0
votes1
answer119
viewsA: Problem with Pytest
Use: from Bhaskara import Bhaskara Then he will carry the class "Bhaskara" inside "Bhaskara.py". By the way, the calcul_roots() method is wrong because it waits three numerical values and you are…
python-3.xanswered Giovanni Nunes 2,638 -
0
votes2
answers846
viewsA: Access denied when trying to push to Github
Check the repository’s ". /. git/config" file, it may be configured locally with this user.
gitanswered Giovanni Nunes 2,638 -
1
votes1
answer116
viewsA: Changing the Mysql version
Starting with Mysql 5.7 the default behavior of Mysql has been modified and the mode ONLY_FULL_GROUP_BY inserted by default. If you do: mysql> SET sql_mode = ''; And it will be possible to run…
mysqlanswered Giovanni Nunes 2,638 -
0
votes1
answer426
viewsA: Add all my modified files per command line to bitbucket
You switched to the business Alteravalorvenda, made the changes, then used git add . (this command accepts wildcards and even more than one file per line) and then git commit, correct? You used the…
-
0
votes2
answers98
viewsA: Python problem using . Join
If it’s just for screen printing, you can try a simpler solution: >>> addr='0a1b2c3d4e5f' >>> '{0}{1}:{2}{3}:{4}{5}:{6}{7}:{8}{9}:{10}{11}'.format(*addr) '0a:1b:2c:3d:4e:5f'…
python-3.xanswered Giovanni Nunes 2,638 -
1
votes2
answers209
viewsA: Creation of a module
Whereas you want to put your routines inside a separate file. For example you have the routine media() in your program: def media(a,b): return (a+b)/2.0 print(media(4,2)) Then you put in a separate…
-
0
votes1
answer235
viewsA: "Roadmap" for learning
It is easier if you already have some notion about programming languages (variable, function, objects, conditions etc), in the Codecademy has a good online (and free) Python course. The Code School…
-
0
votes2
answers654
viewsA: Ruby error after updating Ubuntu
Make sure that Ruby version 2.1 is installed using dpkg -l ruby2.1 (must have a ii on the left) or even if you are in PATH with which ruby2.1 (shall return /usr/bin/ruby2.1). If both tests are…