Posts by gato • 22,329 points
373 posts
-
7
votes2
answers2792
viewsQ: What status code to use when there is no database record to return on an HTTP request?
I own an endpoint that returns a list of products. Therefore, if there is data from this list I set the HTTP status code to 200, and if there is not, I return only a json saying that no record has…
-
21
votes1
answer21108
viewsQ: What is the purpose of the RESTRICT, CASCADE, SET NULL and NO ACTION options?
When creating a foreign key type relationship between two tables in Mysql, I can specify some additional options in the events ON UPDATE and ON DELETE that are associated with alteration and…
-
15
votes1
answer3432
viewsQ: What is the purpose of Middleware in relation to Apis and Web Applications made in Slim?
I’m reading regarding Middleware no framework Slim, however, I could not understand the purpose of Middleware in relation to Rest Apis or Web Applications built in Slim. I was also talking to…
-
11
votes1
answer4142
viewsQ: What is page fault?
I was reading the reply of the user Maniero regarding overlay and memory management. He cited the page fault which can occur when a program is running. However, this term page fault caused me some…
-
4
votes1
answer5675
viewsQ: What is "overlay" and what is its connection to memory?
My college professor was talking about the term overlay in relation to memory. I was confused about this term. I’d like to know what it is overlay and what connection it has with memory?…
-
6
votes1
answer930
viewsQ: How does the White Box Test work?
I read in this reply user’s utluiz the following description of the White Box Test, see: White box test: when assessing the internal functioning of the software. For example, if certain methods…
-
1
votes3
answers842
viewsA: Check two or more occurrences of a listed element (lambda/Linq)
See this form using the method syntax: var listCard = new List<string> { "7720890002560", "7720890002560", "7777777002560", "7720890002560", "7720444402560", "7720777002560", "7728888802560",…
-
7
votes1
answer6487
viewsQ: How does a function run automatically without being called?
I can create a Javascript function and call it as follows: funcaoTeste = function() { console.log('Ola funcao teste'); }; funcaoTeste(); To perform the function I need to call her funcaoTeste(),…
-
4
votes1
answer47
viewsA: When copying the code it gives an error using the WHILE function in C
An important tip is to enable all warnings displayed by the compiler. See the warnings of your program: See the first Warning, he’s saying he expected a int * instead of a int, as its variable…
-
17
votes3
answers1870
viewsQ: What is metadata for HTML documents?
I’m reading a book about HTML. Page 19 lists the Categories. Each element in HTML may or may not be part of a group of elements with similar characteristics. And then the categories of these groups…
-
1
votes1
answer4788
viewsQ: Do the tags that have no closure have any particular purpose?
I often come across tags HTML being used in two ways. First form: <title>Stackoverflow</title> Second form: <meta charset="utf-8"> Note that in the tag title there was closure…
-
12
votes1
answer1898
viewsQ: What is Class Coupling?
I was reading this reply in relation to the design standards relating to Serviceprovider and Servicecontainer, however, the AR Euler01 cited a pattern that mentions class coupling, and it was at…
-
10
votes1
answer2605
viewsQ: What is Service Container?
I was reading about Service Container in Laravel, however, I could not understand very well the purpose of this resource. I know that to create new services we have to use some Laravel methods:…
-
9
votes2
answers373
viewsQ: What is the purpose of the Model folder of the Inphinit framework?
In the Inphinit micro-framework there is the Model folder inside the folder application, and that’s where the classes are, but I’m very confused about those classes. See a class inside the Model…
-
3
votes1
answer73
viewsQ: What is the purpose of the INPHINIT_START, INPHINIT_ROOT, INPHINIT_PATH and INPHINIT_COMPOSER constants?
I’m studying about the micro-framework Inphinit. And in the index.php file are declared some constants that left me confused regarding their purposes. Code of index.php: define('INPHINIT_START',…
-
1
votes2
answers538
viewsA: How do you test a number and tell if it’s prime or not?
You can use this function to check if the number is prime: #include <stdio.h> /* Retorna 1 para numeros primo ou 0 para numeros que nao sao primos.*/ int IsPrime(unsigned int number) { if…
-
3
votes4
answers135
viewsA: Remove items an array containing only 1 character
You can check the size of the characters in a loop, and remove if the value is a character. Code: <?php $arr = ["gato", "g", "stack", "ba", "t", "foo", "à", "é", "bar"]; foreach($arr as $key…
-
1
votes2
answers3399
viewsA: Create an algorithm to identify days of weeks in c++
If you want to get the day of the week through a date 05/03/2017 will have to make the calculations for the year, month and day. See the algorithm I adapted to return the names in English: #include…
-
7
votes2
answers408
viewsQ: What is Strategy Pattern?
I was reading about Strategy Pattern, however, I could not understand it very well and I was confused about its functioning. Doubts What is the Strategy Pattern? In which scenarios should I use it?…
-
50
votes4
answers11718
viewsQ: What are the differences between web application and desktop application?
I always make confusion with web application and desktop application, I can not understand very well the differences of both. Questions What are the differences between web application and desktop…
-
18
votes2
answers3974
viewsQ: What is "word" of a CPU
In my Operating Systems class the teacher quoted a term that left me a little confused, which is word of a CPU (Central Processing Unit) and he did not elaborate on the explanation of this term,…
-
5
votes2
answers2603
views -
29
votes3
answers514
viewsQ: What is the purpose of the software development sequence steps?
I was reading the answers to the question When to use Waterfall and when to use Scrum? and came across something cited by the user utluiz which left me with doubt, which is the sequence of software…
-
2
votes1
answer154
viewsA: Datetimepicker with custom dates
I couldn’t find an option to restrict certain dates in the Datetimepicker component, you may need to use a third party component to do what you want as suggested by the @rodrigorf comment or create…
-
2
votes3
answers1157
viewsA: Regex check IP
An alternative is to use a method of its own, such as this to validate IP in the form of Ipv4: public bool ValidateIPv4(string ipString) { if (String.IsNullOrWhiteSpace(ipString)) { return false; }…
-
3
votes2
answers354
viewsQ: How to generate an array of years dynamically containing the index as the year and the value as the year itself?
I have a routine that generates a list of years dynamically from an initial year defined in the array which in this case is the year 2015 to the current year. See the array structure: $rray = array(…
-
14
votes2
answers225
viewsQ: What is Fastexpando/Fastexpandoobject?
Was reading about Dapper and I came across a feature of him called Fastexpando or Fastexpandoobject, I didn’t understand very well and I had some doubts about this feature. Doubts What is…
-
3
votes2
answers220
viewsA: How to map and obtain only one property or field of a query?
An alternative to getting only one field in an SQL query using Dapper is to specify its type, see an example: using (conexao = new SQLiteConnection(StringConexao)) { conexao.Open(); var sql =…
-
2
votes4
answers110
viewsA: Why this division in the class instantiation in C#?
On the line: Farmer farmer = new Farmer(){ NumberOfCows = 15}; means that the attribute NumberOfCows is being initialized, see you can do this way, example: Pessoa p = new Pessoa { Nome = "Gato",…
-
6
votes3
answers234
viewsA: Global variables recursion
In relation to recursiveness I can’t say whether it is "appropriate" to use global variables, even more so in your case, there are other ways to add the positives of the vector without having to use…
-
4
votes1
answer666
viewsA: How to make Join with more than two lists?
Linq has the command join which allows you to join tables or lists according to an established criterion, in this case the criteria used are the Ids of your lists Cbo, Profissional and Vinculo. I…
-
4
votes2
answers220
viewsQ: How to map and obtain only one property or field of a query?
I’m using the Dapper that has the purpose of map properties of objects. See a practical example: var servico = conexao.Query<Servico>(statement.ToSql(), new { IdServico = id }).First(); That…
-
6
votes2
answers137
viewsA: How do I compare the keys of a hash to a user input?
You can use the library csv to do the Parsing in the CSV file and look for some value of a given field. In your case the value to be researched would be the ID provided by the user, see below an…
-
11
votes3
answers1813
viewsQ: How to map 1:N (one to many) in Dapper?
I’m using the Dapper which is a micro ORM used to map objects according to the database tables following the relational model. Therefore, I have some doubts regarding the mapping and the structure…
-
3
votes4
answers810
viewsA: Python, How to let the person put a number and with this number put that same amount of questions
If your intention is just to have a list of materials stored as a string, you will only need to use a list, and Python has a certain ease regarding list manipulation. See an example based on what…
-
2
votes2
answers855
viewsA: Make comparison using String.Contains() disregarding Casing
An alternative is to use the class Regex to check the disregarded Casing string, example: string foo = "Gato"; string bar = "gATo"; bool contains = Regex.IsMatch(bar, foo, RegexOptions.IgnoreCase);…
-
6
votes2
answers3355
viewsA: Search item in a list using LINQ
An alternative is also to use the query syntax from Linq, it is a bit similar to Sql, see an example: List<string> lista = new List<string>(); lista.Add("JOAO"); lista.Add("Maria");…
-
7
votes1
answer255
viewsQ: How does function pointer work in PHP?
In C it is possible to use pointers in functions to reference other functions, see an example: int somar(int a, int b) { return a + b; } int (*sPtr)(int,int); int main(void) { sPtr = &somar; int…
-
7
votes2
answers1332
viewsQ: Are Quias the differences between Web App, Native App and Hybrid App?
Whenever I do research on mobile development I come across three terms that appear a lot in the surveys. Those terms are: Web App Native App Hybrid App And this generated me some doubts that I would…
-
7
votes3
answers4250
viewsQ: What is the purpose of the "header()" function?
In my question about the HTTP protocol understood that HTTP requests have a format that is described by the protocol itself. However, in PHP there is a function that sends data to HTTP which is the…
-
3
votes0
answers37
viewsQ: How does the "Rewriterule" command work?
I’m studying about the file .htaccess and how page forwarding occurs. Reading about URL friendly I had doubts about the command RewriteRule, more specifically to its operation, they come just below.…
-
3
votes3
answers1358
viewsA: How to create a variable through the answer typed by the user in Python?
If the idea is to use variable variables you will need to use a dictionary to do this, as mentioned by @Luizvieira. However, it is not the same thing as PHP and I don’t know a Python engine that can…
-
34
votes3
answers1426
viewsQ: How does the HTTP protocol process requests?
HTTP methods are used to send and receive data from the server, such as the GET (recovers data) and the POST (sends the data). Following the above definition to understand very well the purpose of…
-
5
votes1
answer2175
viewsQ: What is the purpose of the "ready()" function?
In scripts written in jQuery I always come across a function that is the function ready(), as the first function to be executed, see an illustration example of it: <script…
-
14
votes3
answers30488
viewsQ: What is the difference between "{ }" and "[ ]" brackets?
The JSON file format uses two types of symbols to organize the data in its structure, they are: Square brackets: [ ] Keys: { } In them it is possible to insert values of several types, see this…
-
7
votes3
answers815
viewsQ: In PHP are all variables declared global?
In C# there is the concept of local variables, see the example below: if (true) { int valor = 10; } else { valor = 5; } Console.Write(valor); The above code returns an error saying that the variable…
-
5
votes1
answer139
viewsQ: What is the purpose of the "system" directory of the micro-framework Inphinit?
I intend to use the Inphinit micro-framework on a project of mine, but first of all I need to know more about it. Being so, I created an example project just to familiarize myself with its…
-
11
votes1
answer1523
viewsQ: What is the purpose of the "use" command and what is its relation to anonymous functions?
I am doing some tests with a Restful API that I am creating using the Slim micro-framework, and in one of these routines that is responsible for executing a certain action caught my attention a…
-
11
votes1
answer2240
viewsQ: What is the purpose of the "assert()" function and when should we use it?
According to the PHP manual assert - Check whether a statement is FALSE Or assert() checks the informed assertion and takes appropriate action if its result is FALSE. And there’s this example of…
-
2
votes2
answers133
viewsA: Check if the installation source is from the play store
You can use the method String getInstallerPackageName(String packageName) class PackageManager it will return the package name corresponding to the installation package from the play store, you just…