Posts by Wallace Maxters • 102,340 points
1,984 posts
-
5
votes1
answer3840
viewsQ: 'Dict' Object has no attribute 'has_key' in Python3
In Python 2, when I wanted to know if a dict had certain key, I used the method has_key. if kwargs.has_key("code"): self.code = kwargs.code However, now that I ran the same script in Python 3, I got…
-
6
votes1
answer2127
viewsQ: How to clone objects in Python?
In some languages, besides being able to instantiate a class to construct a given object, we can also clone an existing instance, if we want an object with the same characteristics of the current…
-
14
votes2
answers419
viewsQ: What are private and public Keys?
After I got caught and broke my head to install ssl certificates in Apache, some questions arose in my head regarding some nomenclatures that were appearing according to the searches I was doing to…
-
1
votes1
answer55
viewsQ: Apply size to a textarea, unless it has the attribute "Rows"
I have a textarea which is formatted with the following rule: .wm-form textarea{ min-height:100px; resize: vertical; width:100%; border-radius:4px; border:1px solid #ccc; } <form…
-
1
votes1
answer745
viewsA: Problem Routes Laravel
The error is occurring because reading the application is being done from Laravel root folder and not from the folder public. If you are using Apache, your application needs to point to the folder…
laravelanswered Wallace Maxters 102,340 -
2
votes1
answer984
viewsA: What is the best way to use Notifications in Laravel 5.3
First, you need to understand what you are using when making use of use Notifiable. This is about a trait. A trait in PHP is a code reuse engine that aims to solve methods inheritance problems. With…
-
3
votes1
answer347
viewsA: Use Auth class in Laravel configuration file
This error usually happens because the configuration file is loaded before the internal processing that Laravel does for the class Auth (which is an alias). In addition to this problem, depending on…
-
2
votes2
answers836
viewsA: How to set a header with a JWT token in a request made by the Requests library?
The published answer solves the problems well, but just as an addition I would like to say that it is also possible to make use of JWT without installing a library. Just define a header…
-
3
votes1
answer8794
viewsA: No module named numpy
You need to install the NumPy. If you already have the pip installed, just run the following command: pip install numpy If you don’t own the pip installed yet, you need to download the get-Pip.py.…
pythonanswered Wallace Maxters 102,340 -
11
votes3
answers4722
viewsA: How to make a border lower than 1px?
When I’m having problems in the pixels of border, rather than define 1px solid black, i use thin solid black. See (Zoom in on the browser to notice the difference): .px-border{ border:1px solid…
cssanswered Wallace Maxters 102,340 -
2
votes1
answer1791
viewsQ: Is it possible to make a "text for voice" with Pyqt?
I’m learning to play with Pyqt. I’m building a simple application, where there will be a voice notification when a new request is available. I wish my application written in Pyqt4 could "turn" text…
-
5
votes2
answers836
viewsQ: How to set a header with a JWT token in a request made by the Requests library?
I’m using the library Requests Python to make HTTP requests. I was able to post a request quietly in order to obtain a JWT token. But now I need to send this token through a header, but I have no…
-
4
votes1
answer676
viewsQ: How to input a password (password field) in Pyqt4?
To use a field similar to input HTML in Pyqt4, I use QtGui.QLineEdit. But how do I make a field that looks like the input password, which is a specific field to enter passwords? You can define the…
-
24
votes6
answers40933
viewsQ: Does ternary surgery exist in Python?
I often see several programming languages where a ternary operation is almost always identical. (x % 2 == 0) ? "par" : "impar" However, when I went to try to do this in Python, it was wrong: (x % 2…
-
2
votes4
answers9085
viewsA: NOT operator in python
In your case, you could use the operator not or else check using the comparison operator == coming if it is False. if tem_vaga() == False: // Não tem vaga if not tem_vaga(): // não tem vaga…
-
4
votes3
answers216
viewsQ: Why is the behavior of the undefined variable different from the undefined property?
I’ve noticed this for a long time in Javascript. If I write a certain code where the variable is not defined in any scope, an exception is thrown: console.log(preco) Upshot: Uncaught Referenceerror:…
-
6
votes6
answers2755
viewsA: Is it bad practice to use only static methods in a class?
I couldn’t resist also having to post an answer. This is good practice? It has already been said by @Maniero that "good practice" or "bad practice" is sometimes simply a modinha that everyone wants…
-
4
votes2
answers1564
viewsQ: Is it correct to use the Input tag within a Label tag?
I was taking a look at the tutorial from W3schools, where he’s teaching to use the input of the kind checkbox in Bootstrap. According to one example, I saw the following code:: <div…
-
3
votes1
answer259
viewsA: Too Loud for Too Many?
You should use checkbox. So, you could assemble your form in a similar way to this: <form method="POST"> @foreach($exercicios as $exercicio) <label> <input type="checkbox"…
-
9
votes2
answers687
viewsQ: How do I know if a class implements an interface?
In PHP, we can implement one (or more) interface in a class. Thus: interface Authenticable { // métodos } interface Model { // métodos } class Person implements Authenticable, Model { // métodos }…
-
2
votes1
answer68
viewsA: Pass captured data from a Python code to Shell Script
Do so: from subprocess import call call(["sh", "caminho_do_script.sh", temp, umid]) You will need to use a list. The first item of this list is the command, and the rest, the arguments. In the above…
-
2
votes1
answer127
viewsA: Get sibling id of the item that effected event
Use siblings: $(":input").bind('keyup mouseup', function () { $(this).siblings(':hidden').val(); }) Another detail is that you have to use type=hidden instead of hidden. <input id="CdProduto"…
-
1
votes2
answers786
viewsA: Count lines
I think what you’re looking for can be done with withCount. This method you use to bring the counting of relationships. Behold: $produtos =…
laravel-5answered Wallace Maxters 102,340 -
1
votes1
answer230
viewsA: Is using an absolute path in a require() function enough to prevent attacks?
Setting the absolute path to directories avoids accessing other folders? No. Because if the "attacker" puts ../, knowing the file path, it may access an unwanted directory in any way. That is, for…
phpanswered Wallace Maxters 102,340 -
4
votes1
answer414
viewsQ: Is it dangerous to leave mod_mime_magic active in Apache?
Once I was arguing with a programmer more experienced than me (the user @Bacchus) about uploading files. I was commenting on it not making sense for someone to try to upload a file with extension…
-
5
votes3
answers331
viewsA: PHP remove a URI snippet with regular expression
On my Github I created a gist with a function to do operations like this in a reusable way. Besides, I prefer not to use regular expression, as these usually cost more in terms of performance. This…
-
3
votes1
answer1079
viewsQ: How to block resizing a widget/window?
I am setting a certain widget according to the size of the secondary monitor. This I managed to do perfectly. However, as I am beginner with Pyqt, I would like to know how to block window resizing.…
-
2
votes3
answers9006
viewsA: How can I make a Brazilian time clock in real time
With jQuery, I once did so: var $clock = $('#real-clock'); setInterval(function () { $clock.html((new Date).toLocaleString().substr(11, 8)); }, 1000); You can do it with pure javascript too: var…
javascriptanswered Wallace Maxters 102,340 -
4
votes3
answers220
viewsQ: Attributeerror: 'Qstring' Object has no attribute 'strip'
I’m making a small application in Pyqt4 to understand how it works. In a certain part, I’m using a callback function to display in a QLabel the text that is typed in QtextEdit. This text should be…
-
4
votes1
answer330
viewsA: Is there a PHP library or plugin for field validation?
Respect Validation The Most awesome validation engine Ever created for PHP Translating: The most impressive validation engine ever created for PHP I really agree. The guys thought of everything when…
-
3
votes3
answers1005
viewsA: Foreach by reference or by value?
Performance I’m not an expert on the subject, but I can assure you that the performance in this case doesn’t make so much of a difference that it’s worth choosing one or the other because of it.…
-
1
votes2
answers145
viewsA: Object property from JSON is not accessible
In Laravel there are two ways to carry the relationship: Eager loading constraints and Lazy loading. The first, which is Eager loading constraints (anxious loading, load the relationships in…
-
8
votes2
answers2062
viewsQ: What is the difference between angular.extend and angular.merge?
At the angle, to extend an object, I usually use `angular.exted var obj = {nome: "wallace"} angular.extend(obj, {idade: 26}) Upshot: Object {nome: "wallace", idade: 26} However, I realized that by…
angularjsasked Wallace Maxters 102,340 -
6
votes2
answers166
viewsQ: What is the Countable interface for in PHP?
I saw a certain class whose statement was that way: class Collection implements Countable {} I realized she was implementing Countable, but I didn’t understand what this implementation was doing…
-
0
votes3
answers245
viewsA: Error doing Join with Laravel Query Builder
In versions prior to Laravel 5.3, no query results from Fluent returns Collection, and yes a array. As Virgil says, use count($data) instead of $data->count(). Just giving more details, When you…
-
4
votes1
answer1465
viewsA: How Pdostatement::fetchObject works
In this case, you do not need to define a constructor. When you use PDOStatement::fetchObject to determine which object will be used to represent the data coming from a query, the PDO will define…
-
3
votes1
answer57
viewsA: Accessing information from an Object
If the data is repeated, you can use a loop to access it. foreach ($object->c as $key => $value) { echo $value->type; echo $value->cm; } If you were to access directly, it would be so:…
-
15
votes2
answers6664
viewsA: How to create and manipulate lists in PHP?
PHP is not a language with much type discipline. In PHP there is a resource called array. The array can be a numbered or indexed list - and can also be both at the same time. For example: $arr = [];…
-
4
votes2
answers833
viewsA: Varchar or Datetime?
On the face, the first advantage I can talk about DATETIME is that when comparing intervals between dates, you waive the use of functions to make conversions to find a result. Example SELECT * FROM…
-
1
votes2
answers73
viewsQ: How to use an angular service outside the angular structure?
On the corner we have a service called $http. I know to call it just pass as a parameter of a closure, that the angular does the magic: angular.module('foo').controller(function ($http) { /** ...…
angularjsasked Wallace Maxters 102,340 -
1
votes2
answers1031
viewsA: What’s the difference between bindValue and an array executed directly in $Pdo->execute()
As an addition to the @rray, would like to highlight here the advantage of using the execute with array in relation to the method PDOStatment::bindValue. Often the data we want to pass to the…
-
5
votes1
answer9626
viewsA: Warning: Invalid argument supplied for foreach()
Error because your method does not return an iterable value via foreach. The method SelectLastError should return a array, since you want to use it later in a foreach. You are adding the results in…
-
2
votes4
answers3793
viewsA: How can I put a negative number in PHP?
Just match as the negative sign on the front: $x = 2; $x = -$x;
phpanswered Wallace Maxters 102,340 -
3
votes1
answer177
viewsQ: How can I turn an INI file into a Dict?
How can I transform data from a file .ini in a dict in Python? Is there any way to do this in Python? [database] host = localhost password = sabe_nada_de_python port = 3306…
-
5
votes2
answers184
viewsQ: How to turn an INI file into an Array?
How can I turn a file INI in a array in PHP? Example: [database] host = localhost password = sabe_de_nada_inocente port = 3306
-
0
votes0
answers67
viewsQ: How to choose the default folder when performing the "Styles" and "scripts" functions of Elixir?
Using the Laravel Elixir, I usually use the functions styles and scripts to concatenate the Assets to a single file. However, it seems that by default these two functions try to read files from the…
-
3
votes1
answer977
viewsQ: How does Laravel read the file ". env"?
How Laravel does to read the file ". env"? I’ve looked in the repositories of Illuminate (from Laravel) and I didn’t find anything that gave me a hint of how to read this file. Is there a library…
-
1
votes2
answers246
viewsA: Set connection according to logged user data
I noticed that you are trying to access the user data without checking whether it is authenticated or not. You need to define a behavior if the user is not logged in. The way you did probably gave…
-
8
votes3
answers939
viewsQ: What is the difference between Directoryiterator and Filesystemiterator?
In PHP, there is the class Directoryiterator. The Directoryiterator class provides a simple interface for viewing the Contents of filesystem Directories. There is also Filesystemiterator, that the…
-
4
votes5
answers2081
viewsA: Hide the last 4 numbers from a string
The question implies that you need to delete the last 3 numbers after the last point. That is, the last 4 characters of the IP need to look like .***. Then I’d do it that way: preg_replace('/\d+$/',…
phpanswered Wallace Maxters 102,340