Posts by vinibrsl • 19,711 points
378 posts
-
1
votes2
answers69
viewsA: Text box to determine amount of digit usage
You can add one more validation textBox1.Text.Count(letra => letra == ',') > 1 If this condition is true, the e.Handled should be true, so he wouldn’t write the comma. Why treat the event…
-
4
votes2
answers81
viewsA: How to restrict a set of a property?
Another way to do it is to expand the property and apply its logic private char[] naipesPermitidos = new char[] {(char)9824, (char)9827, ...}; private char naipe; public char Naipe { get { return…
-
5
votes1
answer4113
viewsA: Count of a specific character in a word in Python 3
Use the str.count: "exemplo".count("e") => 2
-
4
votes1
answer708
viewsA: What does Nodo mean?
This looks like an implementation of a chained list (Linked list). It stores the reference for the next item, if it doesn’t exist, then null. is a linear collection of data elements, the order of…
-
6
votes2
answers6416
viewsA: Check if the string contains only numbers
One of the ways to know if the string contains only numbers, is using a regular expression "1239417".matches("[0-9]+"); // true "12312a".matches("[0-9]+"); // false "12312+".matches("[0-9]+"); //…
-
1
votes2
answers1295
viewsA: Count certain characters in a word in python
You can use the rest of the division by 10 to know how many zeros on the right an integer has: def conta_zeros(n): zeros = 0 while n != 0 and n % 10 == 0: # se não for zero e ainda for divisível por…
-
1
votes1
answer43
viewsA: Argue when calling function
The function price_qtde receives a parameter (units), but by calling this function in the last line of your code, you are not giving any argument. If the value of units should be 2, then do: puts…
-
2
votes1
answer4415
viewsA: How to reuse the Click of a button event in another method?
Modularize Separate the contents of btnReabrirCaixa_Click in a method and call it in ValidarAberturaCaixa and btnReabrirCaixa_Click, as: private void MetodoSeparado() { // ... } private void…
-
14
votes2
answers301
viewsA: What is serverless architecture?
Amazon itself made its definitions of this architecture here (my emphasis) build and run applications without [having to] think about on servers It is not that it is without servers, it is that the…
-
4
votes3
answers510
viewsA: How to make an error message for this situation?
Create a boolean type control variable. I named achou. achou = False # inicializa a variável while(True): for linha in filmes: linha = linha.split(";") if genero in str(linha[1]): achou = True #…
-
1
votes1
answer207
viewsA: What is the difference between stable and legacy versions of jQuery UI?
The legacy (legacy) version is an older version, but one might still need it. In the case of jQuery UI it even has support for it. Sometimes there are dependency conflicts (in this case jQuery…
-
0
votes1
answer51
viewsA: C# Form2 calling Form1
Go to the file Program.cs and there you will find the following line Application.Run(new Form1()); Switch to the form you want to use. In your case: Application.Run(new Form2());…
-
3
votes1
answer163
viewsA: How to return string array of each book with its chapters and verses?
You can structure a little better the way you are dealing with the types. Let’s create a class to represent the book public class Livro { public string Nome { get; set } public List<Capitulo>…
-
0
votes3
answers178
viewsA: How to store a single character?
A string is a char[], a string. I made an extension method: public static char ToChar(this string value) { if (string.IsNullOrEmpty(value)) throw new ArgumentException(); // retorna o primeiro…
-
6
votes1
answer667
viewsQ: What is SSH and what are its advantages over HTTPS?
Some services offer client-server connection through SSH (Secure Shell). What is this SSH? One case is Github, which recommends SSH even though it already offers HTTPS, but HTTPS seems much easier…
-
2
votes2
answers160
viewsA: Equal sign in Ruby method definition
In summary, getter and Setter methods expose class fields. They can expose the field in a raw way, such as [privado] meu_campo = 25 [público] get_meu_campo # retorna 25 [público]…
-
0
votes1
answer326
viewsA: How to change the values of a Hash?
Modifying the values First store the Hash in a variable meu_hash = { [ "Begin", "Dom" ] => 0, [ "Begin", "Seg" ] => 8, [ "Begin", "Ter" ] => 10, [ "Begin", "Qua" ] => 30, [ "Begin",…
-
2
votes1
answer53
viewsQ: Why use Kernel#loop instead of Begin-end-while/until?
I’m making a Ruby repetition structure using the following structure: begin [código] end <while/until> [condição] But the Rubocop, which I use as a tool for linting, says I should use the…
-
0
votes1
answer225
viewsA: Problems with PEP8 indentation rules
The conventions on Hanging indentation of PEP 8 say that the next line should follow the first parameter, not the function itself. See: # faça foo = long_function_name(var_one, var_two, var_three,…
-
1
votes1
answer363
viewsA: How to run scripts in Lua with java program?
The Luaj offers a very simple integration interface between Java and Lua. import org.luaj.vm2.*; import org.luaj.vm2.lib.jse.*; Globals globals = JsePlatform.standardGlobals(); LuaValue chunk =…
-
4
votes1
answer73
viewsQ: Are methods objects in Ruby?
Ruby’s got the class Proc, that is defined in the documentation as Blocks of code that have been bound to a set of local variables. Once bound, the code may be called in Different contexts and still…
-
1
votes1
answer48
viewsA: Consulting cities without repetition and with different "WHERE"
There was a translation error there. He wants different results that have a non-odd ID. To find out if an integer is even, the rest of the division by 2 must be zero. You can represent in SQL that…
-
3
votes2
answers44
viewsA: Why is Directoryinfo.Exists true after deleting the directory?
You need to reinstall the variable directory2 or call the method Refresh() after excluding it (or creating it). directory2 = new DirectoryInfo(Directory_02); // reinstanciando directory2.Refresh();…
-
2
votes1
answer371
viewsA: How to set up a regex?
As pointed out by @Jeffersonquesado: /turn(on|off)/g The first bar indicates the beginning of a regular expression. The parentheses are a capturing group. The pipe acts as a operator ou. Finally,…
-
4
votes1
answer1550
viewsA: Convert Char to string in C#
You are using double quotes, which is the literal of string. That one Overload of the method Split expecting a char. Use simple quotes this way: string[] caminho = path.Split('/'); Of documentation:…
-
2
votes1
answer451
viewsQ: How to join multiple commits from the same file?
I did three commits on even file using git commit arquivo.ext -m "msg". I realized that these three commits would look better together, as if they were one commit. There are ways to do this even…
-
11
votes3
answers31875
viewsA: How to know the version of Angular installed by Angular CLI?
No command line You can search for the version of @angular/common or another Angular dependency on the package.json file in dependencies: "dependencies": { "@angular/animations": "^4.2.4",…
-
15
votes1
answer221
viewsQ: Is there any way to build a useful application based entirely on the functional paradigm?
The functional paradigm, in theory, is beautiful to see. Purism, immutability and determinism. This can facilitate development, decrease the incidence of bugs and help in maintainability. From this,…
-
18
votes2
answers14582
viewsA: What is Basic Auth?
What is? Basic Authentication is the most common authentication system of the HTTP protocol. It is included in header HTTP request in this way: Authorization: Basic {credenciais em base 64 no…
-
2
votes2
answers494
viewsA: How to store an array in a string?
You can use the String.Join when you need a separator. So: string[] nomes = {"Vinicius", "Rovann", "Anderson"}; return string.Join(";", nomes); // Saída: "Vinicius;Rovann;Anderson" If you want to…
-
2
votes3
answers1915
viewsA: Remove element from a vector in C# and don’t leave the vector with a blank space?
To complement the existing answer, it might be worth reviewing the need to use an array. When dealing with adding and deleting elements, it is interesting to use a collection type. From the…
-
3
votes1
answer5565
viewsA: How to remove an item at an array position?
Turn the vector into a List<T> and use the method RemoveAt(int). string[] x = {"3","2","1"}; var lista = x.ToList(); // cria um objeto do tipo List<string> a partir do vetor…
-
4
votes2
answers8557
viewsA: How to run the INSERT script with one million lines in SSMS?
Create a (or several) CSV file with this data using any separator. From there you can use the BULK INSERT. BULK INSERT tbl FROM 'C:\path\data.csv' WITH ( FIRSTROW = 2, FIELDTERMINATOR = ',', --…
sql-serveranswered vinibrsl 19,711 -
12
votes1
answer3054
viewsQ: What is a pure function?
When studying functional programming, I heard a lot of the term "pure function", or Pure Function. What characterizes this type of function and what is its importance for the functional paradigm?…
-
1
votes1
answer695
viewsA: Download all files from a remote FTP directory
One simple way to do it, when you don’t need so much specific control for this protocol, is to use the class WebClient. WebClient client = new WebClient(); client.Credentials = new…
-
7
votes3
answers845
viewsQ: How to declare a constant in Ruby?
How to declare a constant in Ruby? In other languages I do something like: const CONSTANTE = 1024 And CONSTANTE cannot be changed at runtime. But I can’t find anything like this in Ruby.…
-
5
votes3
answers1595
viewsA: Is it bad practice to put numbers as id in HTML elements? If so, why?
My answer tends to detach from the HTML context, although it is fully applicable. This is because the existing answers already answer this side of the question. I want to address a broader concept.…
-
6
votes2
answers202
viewsQ: Why do we pass an object to the statement lock?
I’m working with multithreading and fell in a competition case. More than one thread accessed an I/O operation on the same file and so an exception was triggered. To solve the problem, I did so:…
-
1
votes2
answers135
viewsA: Doubt about access modifiers and polymorphism
The private members of the superclass cannot be replaced (or even observed) by the child classes. Therefore, the method to be considered is that of the subclass Filha. Only members with access…
-
1
votes1
answer275
viewsQ: Pass complex object vs simplest object per parameter
In the method Log there is the type parameter HttpClient. The function only uses the parameter to access the property BaseAddress, which is a Uri. private void Log(string verb, HttpClient…
-
2
votes2
answers59
viewsQ: Taskcompletionsource<Tresult> without a type parameter
The class TaskCompletionSource<TResult> needs a type TResult. That way, when I need to use this class without having a return type (void), I have to do something like: var tcs = new…
-
3
votes1
answer509
viewsA: Take values separated by spaces in C#?
Use the String.Split: var input = "10 15 20"; string[] output = input.Split(' '); // o separador nesse caso é o espaço Then you get a string array. If what you want are integers, convert the array…
-
2
votes2
answers441
viewsQ: Should I cover private methods in unit testing?
In my unit testing coverage, private functions are not tested. I don’t know if this is the right route. Should I test my private methods? All? No. NET, the attribute InternalsVisibleTo makes it…
-
5
votes1
answer183
viewsQ: Pass arguments to the property getter
VB.NET allows you to declare parameters in the property getter Public ReadOnly Property Propriedade(param As String) As String Get Return param & "!" End Get End Property It’s a strange feature…
-
13
votes3
answers1500
viewsA: When to use blank lines in a Python program?
Python Enhancement Proposal These are design documents maintained by the Python community and maintained on Github defining guidelines for better use of language and its resources. These definitions…
-
6
votes1
answer102
viewsQ: How does Visual Studio’s Edit and Continue work?
Visual Studio allows you to edit C#, VB.NET or C++ code in debug when you hit a breakpoint or click the break button (pause icon). The name of the tool is Edit and Continue. According to the…
-
4
votes4
answers581
viewsA: What is the most appropriate method to "connect" a CSS code to an HTML?
TL;DR Only use online styling in the latter case, when you need to superimpose a style already defined on an external sheet and it will never be repeated. To stylization incorporated can be used on…
-
3
votes1
answer571
viewsA: How to call asynchronous method in class builder?
Manufacturers shall not be marked as async. There is a open discussion in the C# language repository on Github on the subject. That said, there is no way to call a method and wait for it with the…
-
7
votes1
answer7312
viewsQ: What’s the difference between a charge test and a stress test?
I read it here that the stress test is (my emphasis) performed to submit the software to extreme situations. Basically, the stress test is based on test the limits of the software and evaluate its…
-
1
votes1
answer87
viewsA: How to put a day, month and year placeholder in Mysql?
If you store your dates with datetime or date there is no way, has to treat in select. It’s quite simple: SELECT data, DATE_FORMAT(data,'%d/%m/%Y') as data_formatada FROM tabela ORDER BY data ASC…