Posts by Leonardo Pessoa • 1,233 points
46 posts
-
0
votes1
answer61
viewsQ: Influence on the chosen AWS region in performance
Logically, comparing two similar infrastructures, it is expected that the closer to the request user respond more quickly. For web applications in AWS in general (not being real time), the…
-
1
votes2
answers95
viewsA: Doubt about importing libraries
If you put the file __init__.py in the folders you want to browse, Python will interpret as packages. See: app.py a/ -- __init__.py -- lib/ ----- __init__.py ----- exemplo.py Assuming you want to…
-
3
votes1
answer222
viewsA: htaccess that hides only directories
Just try this on your file .htaccess: Options -Indexes
-
2
votes1
answer78
viewsQ: Version control of dependencies
Use python, Django on a server with CloudFoundry installed. There, I can keep my requirements.txt with all the dependencies of my application and, for security, I always keep the exact name of the…
-
0
votes1
answer84
viewsA: Can I extend the admin form to my page?
By Django admin, only if the user has access. If you want to create a form based on the characteristics of your models in a frontend, I suggest using the Django Forms. Example: Forms.py from django…
-
1
votes1
answer161
viewsA: Configure Reply-To in form
Replace the code snippet like this: $headers = array('Content-Type: text/plain; charset="UTF-8";', 'From: ' . $_POST["email"], 'Reply-To: ' . $_POST["email"], 'Return-Path: ' . $_POST["email"], );…
-
5
votes1
answer2656
viewsQ: How does a virtual keyboard work for security purposes?
I know you have several posts here citing the pros/cons of virtual keyboards to avoid keyloggers, but I didn’t see any that went into that particular point: How do those virtual bank type keyboards…
-
1
votes4
answers258
viewsA: How is this operator not working in this code?
The ! will always deny the expression that comes forward, so: finished = true; //!finished = false finished = false; //!finished = true;
-
0
votes2
answers75
viewsA: Is it possible to do an Update this way?
The Queries within your SET and WHERE return more than one value because you do not filter which one you are specifically looking for. Understand: UPDATE public.impressoras SET codigoempresa=(select…
-
3
votes3
answers7978
viewsA: Change`id` of <Form> javascript or jquery element
You can try something like: $('#meu_form').attr('id','novo_id');
-
0
votes1
answer146
viewsA: Foreign Key Rendering in Django
You can use the initial, see: >>> import datetime >>> class DateForm(forms.Form): ... day = forms.DateField(initial=datetime.date.today) Or so for a text: >>> class…
-
1
votes2
answers233
viewsA: Classes within classes (Python/Django)
You’re looking for a relationship Many-to-one, see: class Mae(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) class Pai(models.Model):…
-
2
votes2
answers526
viewsA: How do I print jquery results in a div?
You can use jQuery’s HTML command on success of your AJAX request: $('#id_da_minha_div').html(meu_html) See more information here: http://api.jquery.com/html/…
-
0
votes3
answers205
viewsA: How to get mime from a file through Python?
You can use the library mimetypes: >>> import urllib, mimetypes >>> >>> url = urllib.pathname2url('meu_arquivo.xml') >>> print mimetypes.guess_type(url)…
-
7
votes1
answer1008
viewsQ: What are the most common types of databases for web applications?
Some databases store objects, relational structure of tables, hierarchies, etc. What are all these types (models)? When is each application indicated (besides, of course, the developer’s…
-
27
votes2
answers13039
viewsQ: What is CI/CD? Benefits and Risks
It’s very easy to find the answer to the concept on Google but wanted to understand how it works in practice. I know that the Amazon, for example, code migration for each production few seconds. Can…
-
3
votes2
answers634
viewsA: Input text of hours!
You can use the jQuery Masked Input For example: $.mask.definitions['H'] = "[0-2]"; // seta as mascaras $.mask.definitions['h'] = "[0-9]"; $.mask.definitions['M'] = "[0-5]"; $.mask.definitions['m']…
jqueryanswered Leonardo Pessoa 1,233 -
1
votes1
answer200
viewsA: Alternative money_format in php in windows
According to this OS post in English, you can use the Intl Extension. For example: $fmt = new NumberFormatter( 'de_DE', NumberFormatter::CURRENCY ); echo…
phpanswered Leonardo Pessoa 1,233 -
2
votes3
answers1776
viewsA: Get user logged in to Django globally
You can use the request.user available at view that loads the page. See more about using authentication and users on:…
-
0
votes2
answers1818
viewsA: How to make a pop up appear after pressing a button using Jquery UI
The problem is that you do not call the function to show your popup in the button action. Try something like: <script> <!--- jQuery UI “Submit” button ---> $( function() { $( ".widget…
-
0
votes1
answer34
viewsA: How to make a call from a file that contains an ajax form?
You can create several <div>s with different forms and display only the ones you want within your script. For example: HTML <div id='form1'></div> <div…
-
1
votes2
answers319
viewsA: Hide div with fadeToggle when click out of it
Add a click event on body of the document that closes your div: $(window).click(function() { $('.dropdown-login').fadeOut(200); }); And another click event to stop the spread:…
-
2
votes1
answer1025
viewsA: Order form with Python and Django
I suggest you use the API of Forms django. I’m not going to get into the merits of how to build a form because it doesn’t seem like the scope of the question, so I’m just going to emphasize some of…
-
1
votes1
answer2952
viewsA: Typeerror: list indices must be integers, not tuple
On the line... distancia.append((math.sqrt(pow(demanda_X[j] - AP_X[i], 2) + pow(demanda_Y[j] - AP_Y[i], 2)))) ... you take your variable j and i as indexes. However, in your loop, i and j are…
-
1
votes2
answers379
viewsA: SHA512 encryption - XAMARIN
According to this post, the namespace System.Security.Cryptography is not compatible with PCL, but Mono yes. Try something like: protected override byte[] ComputeHash(byte[] data) { var input =…
-
4
votes1
answer387
viewsA: How to get a string with the name of the window that is focused in python?
Try to use the module win32gui: import win32gui window = win32gui.GetWindowText(w.GetForegroundWindow())
-
6
votes2
answers714
viewsA: How do I know if a value is eternal in Python?
I haven’t seen any article or document citing exactly how to do this "great". Meanwhile, the Miku, of Stackoverflow in English, cited some examples. You can try something like: 1- Assuming the…
-
0
votes1
answer772
viewsA: Merge database with java application
You can use the Sqlite. After installing the JDBC driver, you can try something like: import java.sql.*; public class SQLiteJDBC { public static void main( String args[] ) { Connection c = null; try…
-
2
votes3
answers3421
viewsA: Write to files without erasing its contents
You must instantiate the FileWriter with the parameter true, see: try(FileWriter fw = new FileWriter("outfilename", true); BufferedWriter bw = new BufferedWriter(fw); PrintWriter out = new…
-
4
votes4
answers857
viewsA: Compare if variable is number within an if
You can use Javascript’s isNaN function: http://www.w3schools.com/jsref/jsref_isnan.asp isNaN(123) //false isNaN(-1.23) //false isNaN(5-2) //false isNaN(0) //false isNaN('123') //false…
-
2
votes1
answer199
viewsA: Formula for Calculation in jQuery with return
You can assign to your field real the function .change() jQuery $( "#campo_real" ).change(function() { // faça o calculo e atualize o valor no proximo campo ... $(…
jqueryanswered Leonardo Pessoa 1,233 -
1
votes3
answers95
viewsA: Load an element in ajax as user chooses
You shouldn’t wear one yourself id for two different elements. http://www.w3schools.com/TAGS/att_global_id.asp That said, I suggest you remove the function $.post and compare in Javascript itself.…
-
1
votes1
answer25
viewsA: Problem with SWF
Have you tried in pure HTML with the tag object? <object width="400" height="50" data="meu_flash.swf"></object> http://www.w3schools.com/html/html_object.asp…
-
0
votes2
answers531
viewsA: Insert HTML into Link inside Div automatically with jQuery
$( "#popup-imagem" ).find( "a" ).attr("data-popup-open", "popup-1") See more in: https://api.jquery.com/find/ http://api.jquery.com/attr/…
-
1
votes2
answers4336
viewsA: Clear button radio button
Just change the attribute of the checked for false. In jQuery, you can select by id or by name, for example: $('input[name=Choose]').attr('checked',false); In pure Javascript: var ele =…
-
0
votes1
answer561
viewsA: Ajax with Python - I want to call function that is in default
It’s not clear which web framework you use but come on: According to the jQuery API documentation, you can set the attribute method with the POST that will make a POST in any view prepared to…
-
0
votes1
answer59
viewsA: Doubt about music player for website
According to the Youtube: Embed a playlist On a computer, log in to your Youtube account. On the left side of the page, click Playlists. Click on the playlist title you want to embed. Click on Share…
-
0
votes1
answer122
viewsQ: Django makemigrations command (1.9) does not recognize Blank = True in a Boolean field
I have the following model: class Site(models.Model): """ Model for a site entry @author: Leonardo Pessoa @since: 05/09/2016 """ from decimal import Decimal consolidated_financials =…
-
1
votes1
answer122
viewsA: Django makemigrations command (1.9) does not recognize Blank = True in a Boolean field
The field BooleanField does not take as parameter null=True. Instead of that, use NullBooleanField. Has a great answer in Jacob Maristany’s Programmers.se which says: If you allow the use of null,…
-
1
votes3
answers191
viewsA: Enable/disable input text generated by a loop with data received from the database
You cannot have the same ID for more than one HTML element. Behold: https://stackoverflow.com/questions/5611963/can-multiple-different-html-elements-have-the-same-id-if-theyre-different-eleme I…
-
1
votes1
answer5659
viewsA: Generate csv output of python code
To save to CSV, you can use the built-in Python library: https://docs.python.org/3/library/csv.html More specifically the method .write(): import csv # abrindo o arquivo para escrita with…
-
1
votes1
answer1594
viewsA: Find the sum of the elements of a matrix
To add up the sides and identify which one is smaller, you can try something like: superior = 0 direita = 0 esquerda = 0 inferior = 0 for i in range(n): superior += [0][i] direita += [i][n] esquerda…
pythonanswered Leonardo Pessoa 1,233 -
0
votes1
answer181
viewsA: Help with client/server socket with mathematical python sum interactions
You can declare a global variable on the server (socket_servidor.py) to serve as an accountant: soma = 0 ... if data == "exit": exit else soma += data print(soma)…
pythonanswered Leonardo Pessoa 1,233 -
2
votes1
answer2369
viewsA: Read excel information in matrix form with python
According to the documentation, you can also navigate the rows/columns through numbers (indexes). I suggest a loop inside the other: from openpyxl import load_workbook wb =…
-
1
votes3
answers102
viewsA: Valueobjects Django
Even if the address is the same among several people, I suggest you leave it as an attribute of the Person class. Unless they live in the same residence/building, we won’t have as many cases. Will…
-
2
votes1
answer130
viewsA: Is it correct to implement unit test in the model in the context of the Python language?
I don’t believe it’s "wrong" in any language, just a paradigm decision. Python: The framework unittest was originally inspired by Junit and is similar to most unit test frameworks in other…