Posts by Francisco • 7,472 points
260 posts
-
5
votes2
answers1646
viewsA: Regex to replace comma and spaces together
This regex works well: (,?\s+) Entree: "ele, joao gosta de maria, mas maria gosta de jose" Exit: "ele, joao, gosta, de, maria, mas, maria, gosta, de, jose" let string = "ele, joao gosta de maria,…
-
1
votes1
answer392
viewsA: Simpleinjector: The Configuration is invalid. The type is directly or Indirectly Depending on itself
The problem is you’re asking for an instance of BookAppService within an instance of itself, causing infinite recursion. This doesn’t make much sense, you can access the current instance using the…
-
1
votes1
answer320
viewsA: Consecutive sum of a column in SQL
To do this, use the OVER about the function SUM. The OVER will make the SUM apply under one condition, in which case it will be all numbers up to the current "offset". SELECT preço, SUM(preço) OVER…
-
1
votes1
answer2746
viewsA: How to concatenate values within a class in React.JS
In React, you can use javascript codes within component properties using the keys ({}). This is very useful when you need to concatenate values or call functions. With this, to concatenate the…
-
0
votes1
answer118
viewsA: Questions on how to identify an object in the collection
The .Where() does not work in the artPieces because he’s not a IEnumerable, it is an object that contains a list. The best way to catch the object by id would be: var artPiece =…
-
0
votes1
answer57
viewsA: How to do this in LINQ?
If you only want what’s inside the is, it would look like this: List<Hospedagem> hospedagens = new List<Hospedagem>(); for (var dia = comeco.Date; dia.Date <= fim.Date; dia =…
-
11
votes2
answers775
viewsA: What are Truthy and falsy values?
In javascript we have the boolean type variables natively, which can contain true or false. Take an example: if (true) //Dará "true" The value true has a boolean type, ie will return true. But often…
-
1
votes2
answers464
viewsA: Access values within an array
As Phelipe said, you can access the array element using the element keys: $value = $data[0]['id']; But if you want to treat it as an object, you can also do a cast, it would look like this: $value =…
-
0
votes1
answer53
viewsQ: How to pass a value to a list and make it static?
I have a list of objects that I am filling it in as follows: var props = type.GetRuntimeProperties(); var obj = new T(); for (int i = 0; i < readerCache.Count; i++) { var prop = props.Single(x…
-
6
votes1
answer142
viewsQ: Is it worth using binary operators to gain performance?
I have the following situations: if (1 & 1){} and if (1 == 1){} According to what I’ve learned, working with bitwise Operators causes a much better performance in the program, with this I came…
-
1
votes1
answer1142
viewsA: How to run a script on a page without having to open it in a browser tab or window?
One of the ways to do this is by using the iframe, below an example of how to do (examples using jquery). Create the iframe and put the appropriate style to make it invisible to the user: let iframe…
-
1
votes3
answers142
viewsA: Is there any way to get a particular line from a string?
Yes, there is. In moon the terminus of a line is signalled by \n, that is, the solution is to break the line from the \n and take the second element. See how it would look: if s:sub(-1) ~= "\n" then…
-
1
votes2
answers32
viewsA: A doubt regarding the toggle button
To close all that are already open, just iterate on them and give another toggle: $('.clickme').each(function() { $(this).show(0).on('click', function(e) { e.preventDefault();…
-
4
votes1
answer1142
viewsQ: How to run a script on a page without having to open it in a browser tab or window?
I need to make a web-extension (add-on) that can handle DOM elements, existing events and execute scripts in the context of a page of a website. But I need this to happen in background without the…
-
4
votes2
answers280
viewsQ: What’s the difference between creating a string with quotes and square brackets?
I’ve always created the strings with the quotation marks, like this: local minhaString = "Eu sou uma string" I downloaded a source to give a study in the language and I came across the following way…
-
3
votes1
answer9584
viewsA: Syntax error sql, #1064
The mistake is because you are putting simple quotes instead of the accent, the right would be: CREATE TABLE IF NOT EXISTS `chat` ( `id` int(11) NOT NULL AUTO_INCREMENT, `time` timestamp NOT NULL…
-
1
votes1
answer26
viewsQ: How to get the number of users with less time in each Client?
I have 2 tables: CREATE TABLE `deathrun_records` ( `sid64` STRING, `mapname` STRING, `seconds` REAL ); CREATE TABLE `clan_members` ( `sid64` STRING, `nome_clan` STRING, `prop` STRING ); The first…
-
1
votes2
answers113
viewsQ: Error translating structure code from C++ to C#
I’m trying to read a string of a process, I found this structure on the Internet: struct name { wchar_t nome[32]; }; I did it that way: struct name { public char[] nome = new char[32]; } And is…
-
1
votes2
answers331
viewsA: php mysqli last record
The class mysqli owns the int $insert_id, which returns the last id generated by mysql, see how to use in your situation: $query = "INSERT INTO vis_pres_path_foto…
-
1
votes1
answer511
views -
4
votes1
answer320
viewsQ: How to get the Commandtext from a Iqueryable?
I’m trying to catch the sql generated by IQueryable, but is returning: SELECT NULL AS [EMPTY] I expected something like: SELECT i FROM lista WHERE i > 20; Like I’m doing: IDbConnection conn = new…
-
2
votes2
answers128
viewsQ: I can’t get the value of a child element
I’m filling a table as follows: $.ajax({ method: "GET", url: "https://api.github.com/search/users", data: { q: search, sort: "repositories" } }) .done(function( msg ) { jQuery.each(msg.items,…
-
3
votes0
answers603
viewsQ: Error when instantiating Context with Entity Framework
I’m taking the Entity Framework to learn, but when I run my code, it returns the following error: System.Typeloadexception: 'Inheritance security rules were violated by type:…
-
0
votes1
answer23
viewsA: Changing Fields in Database
You can create a PHP routine for this: mysqli_query($conn, "UPDATE Treinamentos SET status = 0 WHERE DATE(NOW()) >= Validade");
-
4
votes2
answers1451
viewsA: I need to know when the user uses semicolons in decimal numbers
To check if he is using a point or comma, you can use the Contains(): string alturaIn = Console.ReadLine(); if (alturaIn.Contains(".")){ Console.WriteLine("Contem ponto."); } else if…
-
6
votes1
answer430
viewsQ: Random always returning the same number
I have a method that its function is to return 25 random numbers on a list: static List<int> criarList() { List<int> lista = new List<int>(); for (int i = 0; i < 25; i++) {…
-
5
votes2
answers202
viewsA: Integer reading via console
What happens is that the Console.Read reads only one character and converts it to decimal according to the ascii table, in your case by reading 2 and converting to 50. Instead, use the…
-
0
votes1
answer196
viewsA: Error - Display an image saved in the BLOB database
Try Find in Base64 before showing it: <img src="data:image/jpeg;base64,".base64_encode($linha['imagem'])." alt='Erro, manutenção necessária!' />
-
4
votes4
answers1339
viewsA: Send PHP command via Ajax?
To better understand the functioning of ajax, we will break your code in parts: Here your code is saying that you want to use ajax to send and/or receive data from another page asynchronously:…
-
3
votes2
answers79
viewsA: Make selection from the results obtained from it
Use the ORDER BY FIELD next to the LIMIT to do this: SELECT * FROM eventos ORDER BY FIELD(id_projeto, 1) DESC, id_evento DESC LIMIT 2
-
2
votes2
answers95
viewsQ: Mysql parameter automation does not work
I’m trying to create a way to automate the business of adding parameters in the query to prevent sql inject, but it doesn’t work! This is my code: public static MySqlCommand…
-
0
votes2
answers1000
viewsA: How to get a list of values common to two lists with LINQ?
If there are two lists with the same type of object, it would not be just you assign to lista2 à lista1 nay? todosEstabelecimentos = estabelecimentosComAcesso;…
-
2
votes2
answers338
viewsA: Error when assigning variable value to vector in C
Instead of: vet[i].cpf = cpfAux; You must use: strcpy(vet[i].cpf, cpfAux); This method copies the value of cpfAux and assigns it to the vet[i].cpf.…
-
0
votes1
answer64
viewsA: How to copy . php file
You can do this with the fopen and fwrite: <?php while ($row = $query->fetch_assoc()){ //Onde $query possui um objeto mysqli_result $nome = $row['nome']; $arquivo = fopen("$nome.php", "w");…
-
2
votes2
answers34
viewsA: Use start and end parameters without using the middle ones. PHP
According to the documentation of PHP: "Note that using standard arguments, any pattern must come after the non-standard arguments: otherwise, things will not work as expected." That is, the only…
-
8
votes2
answers935
viewsA: How to make it play a song when the user puts the mouse on top of an element?
You can combine the onmouseover with the element <audio>: var x = document.getElementById("musica"); function mouseOver() { x.play(); } <audio id="musica"> <source…
-
2
votes1
answer372
viewsA: Delete equal values within a dynamic array
php already has a function that does everything you want: array_unique($array); It removes duplicates and reorders the indices of the array. See working on Ideone. See the array_unique() in official…
-
1
votes2
answers979
viewsA: How to replace string values from all array values?
This is because you are creating an array of different strings in $string. You can fix this using only one variable, in case I used the own $x: $valor = array('1', '2'); $nome = array('valor1',…
-
5
votes3
answers3914
viewsA: How to put the value of a PHP variable inside an input?
You’re doing it right, but in the wrong order. What happens is that you haven’t declared the variable $crTot before trying to use it. To fix, just reverse the order of the php with the HTML:…
-
0
votes1
answer34
viewsQ: Error when trying to insert data into a database
I have the following duties: function query($stmt){ try{ return mysqli_stmt_execute($stmt); } finally{ mysqli_stmt_close($stmt); mysqli_close($GLOBALS['conexao']); } } function…
-
1
votes1
answer27
viewsA: The record is not found in the database when the user logs in
I believe the problem is occurring because you are not passing the appropriate parameters. According to the documentation php, the mysqli_query() asks for 2 arguments: mysqli link - The link to the…
-
1
votes1
answer36
viewsA: How do I update directly to the logged in person?
Just you take the id in the Second that created: public function alterar($nome, $sobrenome, $email, $senha){ $sql = "UPDATE tabela SET usuario_nome={$nome}, usuario_sobrenome={$sobrenome},…
-
1
votes2
answers62
viewsA: Perform function at each given time period
One of the ways to do this is with the time() of time.h: #include <time.h> Code: time_t tempoInicial; time_t tempoAtual; tempoInicial = time(NULL); while (1){ tempoAtual = time(NULL); if…
-
2
votes2
answers331
viewsA: Day count of a date
This can be easily done with the DateTime and the TotalDays: DateTime diaEscolhido = new DateTime(iAno, iMes, iDia); //Cria a variável de datetime com a data escolhida string dias =…
-
3
votes1
answer31
viewsQ: How do I check if a user has a confirmed email with only one query?
I have 2 tables, one of users and one of confirmed emails, which has a user FK and a confirmed user bool: - tbl_valida_email ========================= fk_id_usuario usuario_confirmado I was using…
-
2
votes4
answers130
viewsA: how can I put a condition in if so that it doesn’t happen if the array has "..." at the end of the sentence
I did not understand very well this array, but I will do what I understood: preg_match(".{3}$", $string, $ultimos3); if ($ultimos3[0] != "..." && strlen($string) > $size) See working on…
-
6
votes3
answers342
viewsQ: How to escape characters in Windows Batch?
I have the following script: start "" "https://site.com.br/app/index.jsf?username=nomecabuloso&token=tokenzera" But when I do, it’s only index.jsf, it opens the following url:…
-
0
votes1
answer93
viewsQ: How to compile software through a website?
I’m making a website where one can create software through it. But my question is: How to do this in an automated way? The proposal would be that the software would be made in WPF and the code would…
-
1
votes2
answers447
viewsA: Formatting numbers is not working
To do this, you can join the class CultureInfo with the method ToString: lista.ForEach(e => e.Total = float.Parse(e.Total).ToString("0.00").Replace(".", ",")); Don’t forget to add the use of the…
-
3
votes2
answers124
viewsA: What’s wrong with this loop?
The mistake is that a while cannot be used as a parameter. I believe you want to do it backwards: while (sr.Read(buffer, 0, buffer.Length) > 0) { fs.Write(buffer, 0, read); } Your code is a…