Posts by Wictor Chaves • 8,445 points
320 posts
- 
		2 votes1 answer277 viewsA: Cypress page behaves differently when trying to use two domains in a single testProblem You can disable Google Chrome security to accept forwarding to another domain. Set chromeWebSecurity to false But can’t work with two domains in one test. Same superdomain per test Solution… 
- 
		1 votes1 answer277 viewsQ: Cypress page behaves differently when trying to use two domains in a single testProcedure in Google Chrome I have an Azure B2C login page, enter the user and password and press the "Login" button and then normally. In this process I am redirected to my application page with a… 
- 
		0 votes2 answers365 viewsA: How to check for spaces before, in the middle and at the end of a string using Regex in C#?Check for space If you just want to check if there is space is very simple, just put in the expression only space, see the example: using System; using System.Text.RegularExpressions; public class… 
- 
		0 votes1 answer54 viewsA: Looping ignores the rest of the programProblem You put a string in the second condition, so Python interprets it as a true result: if response == 'pago' or 'recebido': Solution You must put the variable again to compare with the string… 
- 
		3 votes2 answers264 viewsA: Interface or instance of a GenericWarning This is not the answer I’m looking for, this is the best solution I’ve found so far, I’m going to post as an answer that might help someone, not this good, but it’s better than nothing.… 
- 
		1 votes2 answers286 viewsA: Difference between global and local scopeBasically it is a part, for example in the code below, I declared in the first line "var x = 1;" in the global scope, i.e., its scope is the complete part of the code, it is visible throughout the… 
- 
		2 votes2 answers264 viewsQ: Interface or instance of a GenericInterface I wanted to use interface in Dart, but after a lot of searching, discover that there is not, so I did it this way, I created an abstract class: abstract class IModel { String _uid;… 
- 
		0 votes2 answers175 viewsA: How to show value typed in Alert()?In this way: "$quantidade$" You will show the string $quantidade$, to show the value of the variable "quantity", just put the "quantity" in Alert, as in the example below: function funcao() { var x;… javascriptanswered Wictor Chaves 8,445
- 
		3 votes3 answers184 viewsA: How to pass a personized function within a Jquery Change event?Problem When you do that: $("select").change(teste()); You run the "test()" and pass to the "change" function the test return, so the "change" event does nothing. Solution Passing only "test" you… jqueryanswered Wictor Chaves 8,445
- 
		0 votes2 answers117 viewsA: Autowired instance with null valueProblem I used "Autowired" in a class that I installed manually, or I used "new" to use it, so Spring does not inject the dependency. Solution The class that was instantiated manually put the… 
- 
		-2 votes2 answers117 viewsQ: Autowired instance with null valueProblem I am working on a Spring Boot project that depends on other project, these projects are my entities, services and the like. I use the note Autowired to inject my dependencies, example:… 
- 
		2 votes1 answer63 viewsA: How to change the visibility of an input by selecting an item in select and not changing all in ngForThe problem is that you are doing this with a whole type variable: idvalue = 0; To solve your problem, create an array to receive the value of each line: idvalue = []; And change your method:… 
- 
		1 votes2 answers278 viewsA: Why is GIT ignoring one folder and others not within wwroot?Problem Git ignores empty folders. Solution A solution is to simply add a file called ". Keep" to the corresponding folder. Now you can prepare and confirm this file as a consequence, also add the… 
- 
		0 votes2 answers73 viewsA: What makes a code have different visual representations in different browsers?Problem There are some pre-defined rules in the browsers, the border size, spacing and so on, a good solution is to "reset" these rules before you start coding. Solution You can normalize these… 
- 
		1 votes2 answers31 viewsA: index() only for elements with a specific classSimple resolution I select all elements with class "x", I make a foreach until I find the class "index" and then I assign the index to the variable "Indice", returning the value you want in the case… 
- 
		2 votes1 answer156 viewsA: How to make a button clickable after a certain time on Hover?Solution Since the disabled button cannot register the event, I left the active button more with the appearance of a disabled button with css. .disabled{ color: grey; } To prevent the click event… 
- 
		0 votes1 answer110 viewsA: String transformation in pythonProblem Here he understands that all content is one string complete, since you start with single quotes and end with single quotes, and he understands double quotes as part of the string, since you… python-3.xanswered Wictor Chaves 8,445
- 
		1 votes1 answer504 viewsA: Select only folder - HTMLSolution You can take the full path of a file and just remove the file name Code The code below is commented explaining its operation. $('[type="file"]').on("change", function(event) { //Pega apenas… 
- 
		4 votes2 answers111 viewsA: Excel function recognizes "" as 0Easiest way You can do it this way =SE(E(E4=0;E4<>"");"0x0";"") I put an "E", so it also checks if it is different from "" (Empty string) Using an Excel function There is an Excel function… excelanswered Wictor Chaves 8,445
- 
		1 votes2 answers1609 viewsA: Python Mysql database connectionExample using your code You can do this way as described in documentation import pymysql.cursors connection = pymysql.connect(host='reveka', user='carga', password='carga', db='dw') try: with… 
- 
		3 votes4 answers295 viewsA: Print null or non-null in Python arrayResolution Using two for, one to go through "m" and one to go through your sub-items, I created another array for the items that will be summed, but if you are going to use only sums with zero it is… 
- 
		3 votes3 answers1067 viewsA: Index or key in Javascript objectSpeaking a little of your example You’re still an object, as you said yourself in the question {chaves : valor} Only in this case the numbers are the "keys" and the "values" are the objects A small… 
- 
		0 votes1 answer20 viewsA: Update "Validators" using "Directive"Solution I managed to solve as follows, in the builder I inject a NgControl constructor(private control : NgControl) { } So I changed the following line event.target.value =… 
- 
		2 votes1 answer20 viewsQ: Update "Validators" using "Directive"My code I created the following directive to prevent the user from inserting special characters in inputs. import { Directive, HostListener } from '@angular/core'; @Directive({ selector:… 
- 
		1 votes1 answer44 viewsA: Python code in html is not working properlySolutions Comparing strings Its variable categoria is not an integer, so you need to make the comparison using quotes, passing the representation to string, as in this example. {% for oportunidade… 
- 
		2 votes1 answer84 viewsA: CSS for Google Pixel 3 XL resolutionWhat you’re looking for is Google Pixel 3 XL Pixel Size 1440 x 2960 Viewport 412 x 847 Source A table to help you in the future Google Pixel 2 XL 1440 x 2880 pixels, 18:9 ratio (~538 ppi density)… 
- 
		1 votes1 answer446 viewsA: Instantiate class in method parameter or within methodInstance by parameter This way in the place where the "show" method is executed it is necessary to pass as parameter the object "Scroll" public function show(Role $role) { // é apenas um exemplo. }… 
- 
		2 votes2 answers98 viewsA: How to sort array by key and value without losing the original key value?Like asort worked, you can continue using and revert the array using array_reverse with the second parameter true, leaving the second parameter as true their keys are not changed. <?php $array =… phpanswered Wictor Chaves 8,445
- 
		2 votes1 answer82 viewsA: How to put a delay inside another delayYou can do this way, the code is commented explaining its operation. //Proxima função function proximaFuncao(){ console.log('Executando proximaFuncao'); } //Usei o contado para simular um loop, mas… javascriptanswered Wictor Chaves 8,445
- 
		5 votes3 answers297 viewsA: What is Appsettings for?Contains custom application settings. This is a predefined configuration section provided by . NET Framework. Syntax <appSettings> <!-- Elements to add, clear, or remove configuration… 
- 
		1 votes2 answers432 viewsA: How to compare two identical`strings, but different encoded strings?You can use urllib.parse, you decodes the url, then when comparing with the string that this in the file the return is true. import urllib.parse name1 = urllib.parse.unquote('G%C3%A9rard Depardieu')… 
- 
		5 votes2 answers512 viewsA: How to simplify the if command in python?Using Array You can use "in", see this example X = 2 if X in [1, 2, 3, 4]: print("ok") I represented the values using an array [1, 2, 3, 4], so I use "in" to check if the value of "X" is inside the… 
- 
		0 votes3 answers730 viewsA: Datatables export to Excel and format a text column as currency (accounting)For it to be recognized as currency you put to the parameter type with the value currency { "data": "Valor2", "orderable": true, "type": "currency" }, This plug-in will provide numerical… jqueryanswered Wictor Chaves 8,445
- 
		3 votes3 answers318 viewsA: Indentation in statement "Else"Tests to perform Else behavior I performed the following tests, I thought the for with else could be affected by if, by internal variables and by break, to test I ran the following tests. Test 1… 
- 
		1 votes1 answer1045 viewsA: Save data from an html table in PHP arrayYou can take the data using Jquery and send it via ajax to your php page, the code is explaining through the comments. var indices = []; //Pega os indices $('#tblItens thead tr th').each(function()… phpanswered Wictor Chaves 8,445
- 
		3 votes2 answers64 viewsA: Doubt with string, extract dataSearch the words it contains # You can do this way, the explanation is in the code comments using System; using System.Linq; public class Program { public static void Main() { string stringJson =… 
- 
		4 votes1 answer26 viewsA: Instantiated functionsFirst example The difference is that one is a simple function and when you use the new you create an object, see this small example, I am calling the function and the object, realize that when… javascriptanswered Wictor Chaves 8,445
- 
		1 votes1 answer31 viewsA: I would like to display a txt file using JS or PHP respecting line breakUsing a ready-made solution Replace the tag <p> by the tag <pre>, so the page will respect line breaks, if the text is not formatted as you want, just set a style to tag <pre>.… 
- 
		1 votes1 answer56 viewsA: Create "border" in div that does not pass through textYou can use fieldset and legend and set the border normally, as in the example below, I used the padding just to make it more "cute". .conteudo{ padding: 20px; } fieldset { border: 1px solid #000;… 
- 
		0 votes2 answers4326 viewsA: Proxy connection: HTTP 407 Proxy authentication RequiredI had exactly the same error as user21846, in my house the code worked normally, but in the service presented the following error message. Remote server returned an error: (407) Proxy Authentication… 
- 
		0 votes1 answer138 viewsA: Menu Hover JqueryI separated the two functions, created a function "hoverIn" and another "hoverOut", put the event on the button to show the "box-toltip" and in the "box-toltip" I put the event to close, so the… jqueryanswered Wictor Chaves 8,445
- 
		2 votes2 answers74 viewsA: List-group toogle with jQueryI created a div with the "sub-items" class, I leave it hidden using the method hide, until you click on div with the "active" class toggle in the next element that in the case is the div with the… jqueryanswered Wictor Chaves 8,445
- 
		3 votes2 answers832 viewsA: Inheritance and polymorphism in pythonThe only thing I had to change in your code to work was def sobrenomes(self): return super(Sobrenomes, self).nome() I had to put the return in the "last names" method, and put the "s" in the "last… 
- 
		1 votes2 answers60 viewsA: Array of checkbox elementsI created a checkbox which is always selected and hidden, which will be used to be submitted, and other checkbox which is not hidden and has an event, this event changes the value from the occult to… 
- 
		3 votes4 answers110 viewsA: Maintain select element value when cloning with jQuery and deleting LabelsI made a new Jquery function to make the clone, so you can use it elsewhere in the future, and you may happen to have some similar problem in another element, in case this happens you can change… 
- 
		2 votes1 answer74 viewsA: Working in html inside a variableYou can do this way, the code is commented explaining its operation. //String com o html var html = '<input type="text" name="fname"><input type="text" name="fname"><input type="text"… 
- 
		6 votes2 answers1495 viewsA: Take the values of all select options with jQueryFirst thing I did was remove the "example" id, since an html page cannot repeat an id. You can do it this way var valores = []; $('#select_exemplo').find('option').each(function() { var valor =… 
- 
		5 votes3 answers127 viewsA: How to clear a list without losing all positions?You can do this way, the code is commented, explaining its operation using System; using System.Collections.Generic; using System.Linq; public class Program { static List<float> lista = new… 
- 
		5 votes2 answers224 viewsA: Delete string until it reaches the character and ":"Simple example See this example for a better understanding of code string url = "uma_frase_aleatória: Ronison"; string resultado = url.Split(':')[url.Split(':').Length - 1];… 
- 
		4 votes2 answers66 viewsA: I need to find out who’s sequence and who’s not, but my logic doesn’t workYou can do it this way $a = array(1,2,5,8,9,10,11,12); $length = count($a); echo $a[0]; for ($i=1; $i < $length ; $i++) { if ($a[$i-1] != $a[$i] - 1) { echo "<br>" .$a[$i]." Saiu da… phpanswered Wictor Chaves 8,445