Posts by Wallace Maxters • 102,340 points
1,984 posts
-
1
votes1
answer102
viewsQ: How to add methods to a Queryset?
I have a model defined in Django. I would like to add to this model a method that returns me part of a mounted query (a Queryset). That is, a method I want to define a method that affects the…
-
2
votes1
answer102
viewsA: Insertion in the bank with relationship N : M
In Laravel, it’s pretty simple to do this. If you know the user ID and the route ID, just use the method attach to do this: Example: Usuario::find($usuario_id)->rotas()->attach($rota_id);…
-
0
votes1
answer333
viewsQ: Is there any way to create an environment variable by IIS?
I have an application running on local IIS and also in production. In this application, I have a feature where, when an error occurs, an email is sent. The problem is I don’t want that to happen…
-
10
votes2
answers565
viewsQ: Why doesn’t Firefox display WEBP images?
I made a slide on a site where I use images that were passed to me in WEBP format. I thought it was all right because in Chrome everything was working. However I noticed that in Firefox (version…
-
3
votes3
answers840
viewsA: How to obfuscate a PHP email by filling part of the characters before @ (arroba) with * (asterisk)?
I thought of crafting in a very simple way using the function substr_replace combined with strpos. Behold: $mail = '[email protected]' substr_replace($mail, '*****', 1, strpos($mail, '@') -…
-
1
votes3
answers840
viewsQ: How to obfuscate a PHP email by filling part of the characters before @ (arroba) with * (asterisk)?
I need to obfuscate the characters of the email, as I’ve seen many websites doing, by filling some characters of this email with an asterisk. I would like the code to be as complete as possible.…
-
0
votes2
answers228
viewsQ: How to run a callback when a CSS animation is closed?
I saw that the angular-Animate can detect when a CSS transaction is in progress or not to apply certain actions. I need to find out how they do it! Example: #square{ background-color: tomato;…
-
5
votes2
answers108
viewsQ: What does the syntax "14px/1" mean in font size declaration?
Back and forth when I take a look at some source code of a site, I find a code that I still don’t understand its meaning when the attribute statement font. Example: p { font: Arial 14px/1; } I’d…
css3asked Wallace Maxters 102,340 -
4
votes2
answers5911
viewsQ: What is rel="Preload"?
I saw in a code snippet of a site a definition more or less like this: <link rel="preload" href="caminho/para/o/script.js" as="script"> I’ve never seen that code before. I wonder what that…
-
1
votes1
answer445
viewsQ: How does "Restore" and "save" work?
I was trying to understand the workings of the methods save and restore of canvas and I looked on the page of MDN. I still don’t understand what the difference is between using them or not.…
canvasasked Wallace Maxters 102,340 -
2
votes0
answers215
viewsQ: Is there any specification for authentication on Websocket servers?
I was wondering what an authentication process would look like on a Websocket server. I intend to use the Javascript API for Websocket. But I would like to have a more restricted and controlled…
-
2
votes1
answer1297
viewsQ: How to upload an image through the clipboard (copy and paste)?
I was taking a look at the functionality of the site Imgur. When you make a printscreen or even copy an image (not the link, but the image, which is an option that is available in most current…
-
3
votes1
answer161
viewsQ: What name is given in C# when we use the expression "new {}"?
When I saw the use of expression new {} I remembered Javascript, where I use new Object and {} are equivalent. Just for study purposes, I made some comparisons, to see if Csharp followed the same…
-
4
votes2
answers255
viewsQ: Is it possible to use ng-model with contenteditable?
I need to use a divwith the attribute contenteditable and the result of that precise value put in a ng-model. I did so, but it seems not to be working as expected: <div contenteditable…
-
2
votes4
answers235
viewsA: Find out which div with the same class is larger
I think you can do this simply without using jQuery or Javascript, huh! With display: flex you can make the images look the same size. Behold: .images{ display: flex; } <div class="images">…
-
14
votes1
answer697
viewsQ: How does the <dialog> tag work? Does it have a future?
Some time ago, reading some articles on HTML5, I learned about the existence of the tag <dialog>. I was curious to know how it works, because currently when it comes to dialogues (also known…
-
2
votes2
answers686
viewsA: How to count the total of records in a limit and offset query?
I think you can do what you want by separating the queries and reusing: $query = $this->comentario() ->with('user') ->where('serie_id', $request->get('serie_id'));…
laravelanswered Wallace Maxters 102,340 -
3
votes4
answers1033
viewsA: How to get PHP session id with jQuery?
I usually like to do things elegantly. I don’t really like the idea of mixing Javascript with PHP. I would do a route (or page) to return a JSON containing all the information needed to be captured…
-
1
votes2
answers595
viewsA: Height x Width - Javascript - External Image
As I replied in SOEN, you can use jQuery, doing so: var src = 'https://i.stack.imgur.com/RWWpy.png'; $('<img>').attr({src: src}).on('load', function () { console.log(this.naturalHeight);…
-
47
votes3
answers10654
viewsA: How to make a progress bar ranging from 0 to 100% with CSS only?
Would that be, young man? .progress{ height: 15px; background-color: #777; position: relative; } .progress .progress-bar{ position: absolute; height: 100%; background-color: #add555; animation:…
-
14
votes3
answers702
viewsQ: Is there any way to make Git ignore space-related modifications or line breaks?
I have a refactoring craze. If I see something missing or with line breaking excess, the first thing I do is fix. I’m using Visual Studio Code in a project and I use GIT to do version control. These…
gitasked Wallace Maxters 102,340 -
2
votes1
answer391
viewsA: How to change the text of the Bootstrap Pagination UI pagination buttons?
According to the reply of SOEN, you can configure globally through the object that configures the UI Bootstrap Paginator through the paginationConfig, as below: angular.module('myapp',…
-
2
votes2
answers868
viewsA: When trying to define column as Unique, error is generated by talking 767 bytes
I solved this problem by changing the charset and the collation in the dataset settings, in config/database.php: //'charset' => 'utf8mb4', //'collation' => 'utf8mb4_unicode_ci', 'charset'…
-
1
votes1
answer600
viewsA: Use the Laravel diff in two Collections
What is the Collection certain? You need to understand that there is a difference between classes Illuminate\Database\Eloquent\Collection and Illuminate\Support\Collection. The first is returned…
-
3
votes2
answers868
viewsQ: When trying to define column as Unique, error is generated by talking 767 bytes
When I try to run a Migration on Laravel, the following error is generated: [Illuminate Database Queryexception] SQLSTATE[HY000]: General error: 1709 Index column size Too large. The Maximum column…
-
6
votes4
answers7774
viewsA: Calling javascript function only once
You can create a function that is named only in the scope in which it is executed and, after executing the addEventListener, call for removeEventListener to remove it. Thus: var button =…
-
7
votes2
answers957
viewsQ: What is the way to truncate a string in Csharp?
I have a scenario where I have set the maximum size of a field. I want to cut that amount to the limit. I am doing this through the Substring, but returns an error when I have a character of smaller…
-
8
votes4
answers814
viewsQ: Why can’t we return a void call in a void return waiting method?
I was doing some C# tests to find out how the return issue works void. I did the following test below and realized that tests 1 and 3 work perfectly, however 2 no. Behold: public class Program {…
-
2
votes1
answer136
viewsQ: Is it possible to omit the numbers of the "String.Format" formatting arguments in C#?
I was seeing that in Python is possible format a string without numbering the arguments. Example: #mensagem = "Meu nome é {0} e minha idade é {1}"; mensagem = "Meu nome é {} e minha idade é…
-
1
votes1
answer27
viewsQ: How to escape Sqldatasource.Filterexpression?
I have a function that adds a filter to the SqlDataSource. That expression contains a LIKE at the consultation. However, if the person places a character such as ', an error (which evidences SQL…
-
6
votes3
answers436
viewsA: How to order the query in the same order as an array used in Wherein?
Method 1 Perhaps the best solution would be to use the Collection of the Laravel, since you are bringing everything with the get. In version 5.5 of Laravel you could use firstWhere to do this by…
-
0
votes0
answers131
viewsQ: Is there a way to use CSHTML (Razor) in ASPX Webform projects?
I was taking a look in that question in Stackoverflow English, because I really find it very confusing to use ASPX files and find the syntax of Razor more user friendly. When trying to add a file…
-
6
votes1
answer149
viewsQ: How do I set the file size in a Download response?
I have an application where I give an answer by downloading a certain file on the server to the client. I zip the image files that are in a folder on the server and give an answer by manipulating…
-
0
votes0
answers39
viewsQ: What is the key word "virtual" in C#?
In C# is seen some class using the keyword virtual in some methods. Example: class Person { public virtual string GetName() { // faz alguma coisa aí } } I’d like to know what this one’s for virtual.…
c#asked Wallace Maxters 102,340 -
2
votes2
answers949
viewsQ: How do I make IFRAME editable?
I remember a long time ago I used a code in a IFRAME that allowed me to type, to put bold or italics in the fonts, inside this iframe. I know it’s not with the option contenteditable, was another…
-
8
votes2
answers690
viewsQ: How do I convert PNG to JPG in C#?
I’m working on an old project that uses ASP Site. I need to convert PNG image to JPG. How to do this? Note: I don’t want to rename the file, I want to transform the mime of image/png for image/jpeg.…
-
6
votes2
answers4078
viewsA: How to show date without time with Date()
I would do so: var data = new Date().toLocaleString().substr(0, 10) console.log(data) But it’s important to report that when I used this, it didn’t work very well in Internet Explorer (as expected).…
javascriptanswered Wallace Maxters 102,340 -
5
votes1
answer853
viewsQ: How to add an external source in an SVG?
I have a logo that I made in SVG, on file .svgexternal, which uses has a text with the name of the company, whose source is Open Sans Light. On my machine works normally due to the fact that I have…
-
13
votes2
answers457
viewsQ: Use "left: -9999px" instead of "display: None"? But why?
I started to wonder about that a little while ago. I read in some article, which I don’t remember what it is, that for "visibility" sake instead of using display: none or visibility: hidden should…
-
0
votes1
answer985
viewsA: Downgrade of package in Laravel
I would do so: Remove the package with the command composer remove illuminate/support Clear the cache with the command composer clear or composer clear-cache. This is important because, when…
-
0
votes2
answers1048
viewsA: Copy value from Textarea to Other Automatically
Using jQuery, just do so: $(function () { $('#texto').on('input', function () { $('#convertido1').val(this.value); }); }); <script…
-
3
votes3
answers120
viewsA: Convert String to Date and remove 1 day from String
Use the method DateTime::createFromFormat. Through this method it is possible to create an object DateTime from any format. Then having the created object we use the method modify, which accepts as…
-
6
votes2
answers405
viewsQ: How do you force git to keep a directory but ignore all the files inside it?
I have a certain folder and logs which is essential to the functioning of my application. I would like to add the same in my repository, for those who replicate does not want to keep creating the…
gitasked Wallace Maxters 102,340 -
3
votes2
answers405
viewsA: How do you force git to keep a directory but ignore all the files inside it?
To do this in the git just add a file .gitignore inside the desired folder and then determined that all the files except the .gitignore will be ignored inside that folder. Structure: logs/…
gitanswered Wallace Maxters 102,340 -
3
votes1
answer19
viewsA: Is it wrong to return $this->something to another value after using the value of a previous assignment?
It is not easier to use the __construct, young man? In your case I would make two modifications: I would add a constructor leaving a default value for the property. And set the property to…
phpanswered Wallace Maxters 102,340 -
2
votes3
answers4280
viewsA: Add minutes in Javascript
Use the Moment js. to make your job easier. Take an example: var hora = documento.getElementById('hrs'); var resultado = moment(hora, 'hh:mm').add(70, 'minutes').format('hh:mm') If the hours of…
javascriptanswered Wallace Maxters 102,340 -
1
votes2
answers1371
viewsA: How to catch event that closes the browser?
It’s not right to use the localStorage if you want to clean it when closing the Browser. The correct approach is the sessionStorage, which behaves similar to an application session, which, once…
-
5
votes1
answer3432
viewsQ: Is there any risk in using "SET FOREIGN_KEY_CHECKS = 0"?
According to what I read somewhere, the FOREIGN_KEY_CHECKS: ... specifies whether or not to check foreign key restrictions for Innodb tables. I mean, if the guy wants to disable the foreign key…
-
5
votes1
answer1627
viewsA: What is the difference between the apache service Reload and Restart?
The reload tells the service to reload your configuration files. This means it should be sufficient to reload the configuration. However, there may be certain services that do not follow this rule,…
-
6
votes1
answer3874
viewsQ: What is the importance of using "track by" in "ng-repeat"?
Whenever I see any article on the internet on how to optimize the render time of ng-repeat, I see comments on the option track by. Example: <div ng-repeat="task in tasks track by…