Posts by stderr • 30,356 points
651 posts
-
3
votes2
answers1854
viewsA: How to make so that after reading a file "txt" it read another one then
One way to list files is through functions FindFirstFile and FindNextFile (Windows): #include <windows.h> /* Para usar as funções de busca de arquivos */ #include <vector> /* Para usar…
-
2
votes4
answers1394
viewsA: How to concatenate two byte arrays in Java?
One way to do this is to store them in one ByteArrayOutputStream: byte[] primeiroArray = "stack".getBytes(); byte[] segundoArray = "overflow".getBytes(); ByteArrayOutputStream terceiroArray = new…
-
3
votes2
answers93
viewsA: Only take the last links from a sitemap
One way to do this would be to use the method Enumerable.Reverse to invert the list, and Enumerable.Take get n elements: List<XElement> lista =…
-
2
votes3
answers4057
viewsA: Get content that is in parentheses using regex
You can do this without using regex: $texto = "Mais de - valor: R$3.21 - Tipo: (+05)"; $parte1 = strstr($texto, "-", true); // Retorna a 1ª ocorrência antes de "-" $inicio = strpos($texto, "("); //…
-
2
votes2
answers313
viewsA: Access variable based elements
One way to do this would be to use a linq expression to select all the Labels of the form, and Enumerable.Zip iterate on the list of Labels and the outcome of select of DataTable: // Simulando os…
-
8
votes5
answers3697
viewsA: How to import a variable within a function of a class?
One possibility would be to pass the variable as an argument to the function main. class CreatePaymentRequestLightbox{ public function main($valortotal){ $pedido_total = $valortotal; echo…
-
8
votes2
answers1823
viewsA: Can I use Empty and isset in a variable?
Power can, but it is redundant. Both have different goals, the empty determines whether a variable is empty (one empty array, FALSE, NULL, 0 number or format string), the isset in turn informs if a…
-
2
votes1
answer788
viewsA: Error change with Object reference message not set for an object instance
It is also necessary to initialize the class Pessoa. PessoaFuncionario pessoaFunc = new PessoaFuncionario(); pessoaFunc.Pessoa.IDPessoa = Convert.ToInt32(txtCodigo.Text); // <-- erro aqui You…
-
2
votes1
answer145
viewsA: Check the URL for a variable passed GET LUA
One way to do this is to use the function string.gmatch: function checkURL(url, parametro) for chave, valor in string.gmatch(url, "(%w+)=(%w+)") do if valor == parametro then return true end end…
-
2
votes3
answers1452
viewsA: Copy value between quotation marks C#
Another alternative is the method String.Substring, used to extract part of a string. To extract only the file name, without the extension, use the function GetFileNameWithoutExtension of namespace…
-
3
votes3
answers776
views -
11
votes3
answers9222
views -
3
votes3
answers233
viewsA: Substitution of variables in the body of the message
Another alternative that can be used is function strtr, it aims at, translate/replace certain characters of a string. Take an example: $texto = 'Bem-vindo ao Stack Overflow em Inglês'; $traducao =…
-
2
votes1
answer207
viewsA: nasm: error: more than one input file specified
The syntax that is used to compile is incorrect, the option -f is used to specify the output format of the file, while the option -a is used to suppress preprocessing and assume that the compiler…
-
1
votes1
answer190
viewsA: How to block mouse scroll in Datagridview?
You can do this at the event MouseWheel. Take an example: Private Sub DataGridView1_OnMouseWheel(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles DataGridView1.MouseWheel Dim mwe…
-
1
votes1
answer536
viewsA: Display student grade in C
You can use another for to show students' grades. #include <stdio.h> #include <stdlib.h> int main() { int notas[10]; int i; for(i = 0; i < 10; i++) { printf("Digite a nota do aluno:…
-
1
votes1
answer996
viewsA: How to make a program download images from a website, page by page, using id?
The syntax of the loop for is incorrect, to declare and use a for it is necessary to prefix it with %%. It is also necessary to use the /L so that the range. FOR /l %%A in (1, 1, 96) DO ( :: Aqui…
-
1
votes1
answer974
viewsA: How can I remove the "Inspect element" from Chromium Portable
It is possible to do this by editing the user preference. Go in the folder of php desktop Chromium v1 and navigate to: phpdesktop-chromium_v1 ⇢ chromium ⇢ Data ⇢ Profiles. Go to the user’s preferred…
-
4
votes2
answers547
viewsA: PHP Text Interpreter
In accordance with mentioned by bfavaretto, the first if is unnecessary, because right below there is another if what makes practically same thing, except that the latter uses the function…
-
10
votes2
answers10851
viewsA: How to return the difference in hours between two dates?
You can use the DateTime::diff to know the interval between two dates, to know the difference in hours, you get the difference in days and multiply by 24. $datatime1 = new DateTime('2015/04/15…
-
2
votes2
answers837
viewsA: Check closed tab
You can use the function setInterval to be checking whether the popup is still open, when it is closed, you cancel the action with the function clearInterval. function aoFecharJanela(){ alert("A…
javascriptanswered stderr 30,356 -
4
votes1
answer128
viewsA: Is there any way to optimize this code?
One way to optimize this code is to eliminate the use of regular expressions, because it involves the process of implanting the engine of the regex in string, what causes a overload, unless it is…
-
1
votes1
answer105
viewsA: HASH is not working properly
It is a logic problem. The error is in how the password is evaluated in the function verifica_hash: if(verifica_hash($senha, $senha_db)){ echo "<meta http-equiv='refresh' content='0;…
-
2
votes1
answer78
viewsA: How to use the Bitsnoop API
You must make a request GET, and send as parameter the key hash, the value of HASH of the archive .torrent, and specify the format json. error_reporting(E_STRICT); include 'Torrent.php'; function…
-
1
votes1
answer203
viewsA: How to go to the end of Scrollview
You can use the function ScrollView.html#fullScroll using as an argument FOCUS_DOWN to move down, and to move up, use FOCUS_UP.…
-
2
votes2
answers65
viewsA: Get two snippets of a confusing string
Using the method String.Substring, you can do it like this: Dim texto As String = "if Argumento1 = Argumento2 ( --statements; );" Dim ifIndice As Integer = texto.IndexOf("if") Dim igualIndice As…
-
3
votes1
answer7188
viewsA: How to get the Magnet link from a . torrent file?
The Torrent RW does not have a function that returns the Magnet Link. Only the Torrent-parse, through function magnet(). Take an example: error_reporting(E_STRICT); include 'Torrent.php'; $torrent =…
-
1
votes1
answer369
viewsA: Grab project URL
One way would be to use the System.AppDomain.BaseDirectory to find files or directories that are in the same project directory. Another way would be to use the Environment.CurrentDirectory, but is…
-
1
votes1
answer113
viewsA: Get two values from a string
One can use the method String.Substring to extract part of the text. Dim texto As String = "def NomeDaVariavel = ValorDela;" Dim indiceVar As Integer = texto.IndexOf("def") Dim indiceVal As Integer…
-
4
votes1
answer530
viewsA: Detect if link is from the current or external domain with PHP
One way to get the current domain is to get the value of the key SERVER_NAME of array $_SERVER. SERVER_NAME: The name host of the server where the script is executed. If the script is running in a…
-
0
votes1
answer119
viewsA: What’s wrong with this code?
You forgot to close the class opening, missing one } in the end. <?php class Aluga { public $nome; public $snome; public $cpf; public $rg; public $tel; public $email; public $status; public…
-
5
votes1
answer239
viewsA: How to get information from. torrent files?
To display file information torrent with the class Torrent-RW, do the following: require "Torrent.php"; $torrent = new Torrent('ubuntu-14.10-desktop-i386.iso.torrent'); echo '<pre>Privado? ',…
-
5
votes2
answers4952
viewsA: How to display "Press any key to continue" in C++?
You can use the function getchar() even. #include <iostream> #include <cstdio> using namespace std; int main() { cout << "Pressione qualquer tecla para continuar..." << endl;…
-
2
votes2
answers1907
viewsA: Pick date and time from a string
An alternative regular expression: (\d{2})-. /[-. /]+( d{4}) s([ d:]+). $texto = "SSC Napoli v Dnipro - Quinta-Feira 07/05/2015 16:05 Horas SSC Napoli v Dnipro - Quinta-Feira 08-06-2015 17:05 Horas…
-
6
votes2
answers1839
viewsA: Which one performs better? For or Foreach+Range?
The for performed mildly better about the foreach, in this case because the function range returns a array of elements resulting from iteration and accesses each item of this. See a comparison…
-
7
votes2
answers298
viewsA: How to generate incremented variables with Javascript?
That maybe it is not possible, if it is, not worth the effort, the use of a array should be more practical. var camadas = {}; for (var i = 0; i <= 20; ++i) { camadas["camada" + i] = 'Hello World…
-
3
votes1
answer4783
viewsA: remove duplicate values in multidimensional array
It is possible yes. One of the ways to do this is to use the function array_unique, whose purpose is to return a new array no duplicate values. See an example: $dupArr = array("A" => "foo", "B"…
-
4
votes1
answer1384
viewsA: Delphi XE7/XE8 - Refresh in database (real-time update)
In general, one can use the events/notifications of the database, the exact term and the implementation depends on the DBMS, as each one uses a mechanism different. Firebird for example, implements…
-
4
votes1
answer119
viewsA: PHP strips in LUA
To make the search case-insensitive, you can use the function string.lower() to convert the letters to minuscules and search for the first occurrence with the string.find(). function stripos…
-
4
votes2
answers1986
viewsA: Access data from an Array that receives 2 Arrays
To walk the array, do so: $array = array("0" => array ( "ProcuraProdutoPedOnline" => array( "cd_familia" => 3, "ds_familia" => "ACESSORIOS") ), "1" => array (…
-
0
votes1
answer501
viewsA: How to create video playlist in Delphi
I’m trying to create a video playlist on Delphi, to play videos by the mediaplayer and does not run all videos chosen, only the first who rotates... This happens because before setting the file in…
-
2
votes1
answer611
viewsA: Problem comparing strings and string being broken into two python lines
First, with the word shuffled. For some reason know which, when giving a print in word scrambled, most of the time it gets broken in two lines. I’ve tried to print it in one separate line in the…
-
3
votes2
answers981
viewsA: Pass each result of an array to a variable
You can filter information from array imposing conditions, only if the key is shopId or paymentMethod, you print. See an example: $response = array('shopId' => 33015842, 'paymentMethod' =>…
-
4
votes3
answers300
viewsA: Recover groups of a regular expression in Perl
In the expression ([\d]+)+ no bracket is required, nor the second addition operator. If you need to put the results in a array to count the number of occurrences found, do: $version="2.2.1-ALPHA30";…
-
1
votes1
answer1384
viewsA: Simulate mouse click
You can use the API SendInput. Synthesizes keystrokes, mouse movements and button clicks. Obs: This function is subject to UIPI. Applications shall be authorised to inject the entree only in…
-
1
votes1
answer523
viewsA: Foreach in PHP skips the first pass
The first passage is not processed because on the line where the occurrence of the word is verified TÍTULO, using the function strpos, is returned to the numerical position of the first occurrence…
-
2
votes2
answers188
viewsA: How can I have a Radio Group with 10 radio Buttons divided into 2 columns and 5 rows?
You can use a Panel or GroupBox to group the RadioButtons. Take an example:…
-
5
votes2
answers178
viewsA: Picking up items with array prefixes
One of the many approaches that can be used for this, is to use the function preg_grep to return items that match a pattern, and to do so, enter the keys of the array with the function array_keys:…
-
2
votes2
answers1792
viewsA: Generate random number with date value and current time with Javascript
Another way to generate this value is to multiply the current date and time (in seconds) by a random value of Math.random(): function datatimeRandom() { return((new Date().getTime() / 1000) *…
-
2
votes1
answer101
viewsA: How can I add the result value to the previous value?
To do this, you can use the operator += (addition assignment) to accumulate the result and initialize the variable res. The code should look like this: #include <stdio.h> int main (void){ int…