Posts by stderr • 30,356 points
651 posts
-
1
votes2
answers63
viewsA: Looping for as a looping parameter while
You can place a condition when iterating: letras = ['t','f','f','t','f'] for letra in [i for i in letras if i != 'f']: print(letra) Ver Demonstração Or put the condition outside the loop: letras =…
-
3
votes3
answers3063
viewsA: Check whether "1" list value contains "2" list
Like mentioned by Dherik, there are other ways to do this in Python, one of them is to use the function itertools.product which is equivalent to nested loops, see an example: from itertools import…
-
16
votes6
answers65891
viewsA: How to convert a string variable to int?
As already mentioned in the other answers, the return of function input() is the type string, the same applies to the function raw_input() in Python 2.x. numero1 = int(input("Informe um numero: "))…
-
1
votes1
answer8204
viewsA: Cannot execute Binary file: Exec format error
Cannot execute Binary file: Exec format error This message indicates that the file format you want to run is not used or supported by the operating system. In your case, the file format is Mach-O…
-
26
votes5
answers2497
viewsA: What is the purpose of the "Spaceship Operator" <=> of PHP7?
The operator <=> is used to make combined comparisons. Returns 0 if the values on both sides are equal. Returns 1 if the value to left is larger. Returns -1 if the value to right is larger.…
-
0
votes3
answers1118
viewsA: Key capture
For Unix-based systems, you can use the functions of header termios.h and fcntl.h to implement the functions kbhit and getch windows. According to these pages 1 2, this can be done as follows:…
-
2
votes1
answer30
viewsA: Getting an Interface from a Type
The documentation of method Object.GetType suggests that the operator TypeOf to check whether an object corresponds to a particular guy. If TypeOf Expression Is IDirectOutput Then Return…
-
1
votes1
answer709
viewsA: Placing values of a memo inside an array
You can use the function ExtractStrings Var Numeros: TStringList; Numero: string; begin Numeros := TStringList.Create; Memo1.Clear; Memo1.Lines.Add('200:80'); Memo1.Lines.Add('177:3306'); try…
-
3
votes1
answer946
viewsA: Dlls error when compiling
Those warnings appear because the DLLS of the system do not have a debugging information file used by Visual Studio. How are warning messages, you can ignore them, if you want to correct, second…
-
2
votes1
answer611
viewsA: How do I see the largest number of a given set of numbers as well as their average?
In fact, the variable y is not a number set, but rather a variable you are using to add the entries of Textbox, it is necessary to store the numbers in a arrayList. Dim numeros As New ArrayList To…
-
2
votes1
answer1342
viewsA: How to leave a semi-transparent Delphi form?
Do the following: Change to true the value of the property AlphaBend form. On the estate AlphaBlendValue you change the level of transparency, the standard is 255. Upshot: Depending on the version…
-
0
votes1
answer425
viewsA: Query information for a Tlistview-related Tabsheet
Do the following: Declare the function below to identify the Form2 from the PageControl: function IdentificarFormulario(PageControl: TPageControl): TForm2; var tab: TTabSheet; I: Integer; begin…
-
4
votes2
answers10495
viewsA: How to get the number of processors and cores from the terminal?
Another way to get this information is to extract it from /proc/cpuinfo. ~$ grep -c processor /proc/cpuinfo…
-
2
votes1
answer288
viewsA: Recursive in Cakephp - Explanation
According to the documentation, the property recursive defines how deep Cakephp should go to fetch the records associated with a data model using methods find and/or read. Imagine that your…
-
6
votes2
answers8059
viewsA: Run Windows Prompt commands and save the output in a text file
You can do this using the class Process: public static string ExecutarCMD(string comando) { using (Process processo = new Process()) { processo.StartInfo.FileName =…
-
1
votes2
answers413
viewsA: Problem with String.Split
You can use the expression ;(?!.*\)|\() to divide the text using as delimiter ;, whatever is in parentheses will be ignored. public static void Main() { string codigo = @"echo ""Olá, mundo!""; echo…
-
0
votes1
answer86
viewsA: Error importing lib material dialogs in android studio
It is necessary to install the android support library. In the menu, navigate to Tools ⇢ Android ⇢ SDK Manager, select and install Extras ⇢ Android Support Repository. Once installed, try importing…
android-studioanswered stderr 30,356 -
2
votes1
answer1219
viewsA: How to download from Delphi?
You can use the function URLDownloadToFile: // Inclua em "Uses" a unit "Urlmon" function BaixarArquivo(const URL, SalvarComo: string): Boolean; var H: HRESULT; begin H := URLDownloadToFile(nil,…
-
5
votes1
answer3054
viewsA: How to use Windows variables in Delphi?
For information about the environment, use the function GetEnvironmentVariable, according to that page, you can use it as follows: function GetEnvVarValue(const VarName: string): string; var…
-
3
votes1
answer82
viewsA: Pass this Comma Numeric function to Point
You can change the decimal separator on the first call of the function gsub: gsub("(%d%d%d)","%1,") -- ↑ Your code stays like this: function getMilharNumber(n) -- critico return…
-
4
votes3
answers1079
viewsA: How to format numbers in Lua?
The form proposed by page Formatting Numbers - lua-users.org is to use the function string.gsub as follows: function formatarNumero(valor) local formatado = valor while true do -- O "." entre "%1" e…
-
1
votes1
answer1405
viewsA: Streamwriter - Cannot access the file because it is being used by another process
In fact there is no other process using the file, it is your own program. The problem occurs in the method EscreverProcesso: Private Sub EscreverProcesso() ' .... If Directory.Exists(LocalAPPProc…
-
2
votes1
answer1332
viewsA: How to Reference a DLL using <Dllimport> and a variable in the path?
I believe this is not possible to do. However, you can add a directory to the process DLL search path using the function AddDllDirectory, but as it is is a recent API, if you are using a version…
-
2
votes2
answers3134
viewsA: Check if a link is active or broken
One way to do this is to perform a request and check if the response code is 200, indicating that the request was successful. See an example using library cURL: /* Argumentos: $url: A URL a ser…
-
3
votes1
answer375
viewsA: Read dbase in PHP
The version of the extension you downloaded should be incompatible with the installed version of PHP. The extension must be thread-safe and your PHP version does not, or vice versa, which causes the…
-
3
votes2
answers217
viewsA: Displaying link name through url
It is unclear what information you want to obtain from URL, but follows below some alternatives. Function parse_url() Use this function to get the components that make up a URL, such as the Scheme,…
-
3
votes3
answers3371
viewsA: Query value within a variable
You can use the function strpos. $texto = 'aqui fica o valor do texto do membro'; $procurar = 'membro'; $pos = strpos($texto , $procurar); if ($pos === false) { echo "A string {$procurar} não foi…
-
2
votes2
answers106
viewsA: How to not automatically sort IN(Mysql)
You can use the function FIELD: FIELD(str,str1,str2,str3,...) Returns the index (position) of str in str1, str2, str3,... list. Returns 0 if str is not found. Example: SELECT * FROM produtos WHERE…
-
2
votes2
answers1939
viewsA: Php <= "value" and >= "value"?
In the second if there is a syntax error $var <= "40" && >= "99" must be $var >= "40" && $var <= "99". <?php $var = "valor"; $varInt = (int)$var; // Faz um cast para…
-
7
votes1
answer870
viewsA: What is Array.Getlength for?
To know the size of one vector, I can only use the nomedovetor.Length, right? Depends, if it’s a array multidimensional the Array.GetLength() should be more appropriate, it takes as argument the…
-
3
votes3
answers126
viewsA: Run block if no exception occurs
I’m not sure if Java provides this feature directly, in any case you can use a controller variable that will indicate if there has been a success in try, in the finally (will always be executed at…
-
4
votes2
answers729
viewsA: POO tables in Lua!
Values are not returned because you are trying to concatenate an object table with a string using the operator .., to print table values, do: var = TP:new({x = 160, y = 54, z = 7}, {x = 180, y = 60,…
-
11
votes3
answers18584
viewsA: How to use gets() in C++?
One should avoid using the gets, because no data entry is checked, when using it you assume that the user will enter a lower or equal amount of characters allocated to the buffer, In doing this,…
-
4
votes1
answer1593
viewsA: How to replace certain letters of a sentence?
You can use the function string.gsub to make the replacements, the default %a represents all letters: function substituirLetras(texto, traducoes) return string.gsub(texto, "%a", traducoes) end To…
-
4
votes2
answers998
viewsA: Regular expression, taking values from HTML
You can use the expression tags?\w+(?=<\/a>), that will capture any word (enter a-z, A-Z, 0-9 and the lower trace _) that is before </a> using lookhead positive ?=. using…
-
1
votes1
answer157
viewsA: Ftpwebresponse.Getresponsestream returning an HTML
This is because the proxy performs the request through the protocol HTTP, and not FTP, the proxy, then perform the commands of FTP required and will return the result to you within an HTTP response.…
-
4
votes2
answers114
viewsA: Make a site not run on any version of IE
One way to detect the browser is by checking the property user-agent, as you propose is response from the SOEN: function msieversion() { var ua = window.navigator.userAgent; var msie =…
-
2
votes1
answer627
viewsA: Use finfo or pathinfo to get the mime type?
Both are used to different purposes. The functions of class finfo are used to obtain information about a particular file, for example: finfo_buffer: This function is used to return the…
-
4
votes2
answers430
viewsA: How to ZIP only images from a folder with PHP?
Follow another alternative, is trying to use the function path_info, if the function does not exist, another means is used to recover the file extension. The arguments the function receives are:…
-
1
votes1
answer45
viewsA: Dynamic Waitforexit process.
This is because when using method Process.WaitForExit, you perform it on thread leading, who is responsible for redesign window, receive messages, etc. Your application is still running, but does…
-
1
votes1
answer129
viewsA: Why are you screwing up Assembly?
In your code there are some mistakes: Was not defined the executable format, if it’s a program console, use format PE console (for x64, use PE64 instead of PE). The point of program entry, to define…
-
2
votes2
answers3587
viewsA: Catch json values in Curl return
One way to be redeeming these values is: $string = json_decode($server_output); $nome = $string->nome; $sobrenome = $string->sobrenome; echo $nome . " " . $sobrenome . "\n"; // Fulano Ciclano…
-
2
votes1
answer51
viewsA: Getting multiple values from a String
It may not be possible to use the method String.Split() for that purpose, regular expressions may fall well in this case, use the method Regex.Split(): Imports System.Text.RegularExpressions '…
-
3
votes1
answer258
viewsA: Listview Customizado
You can do this by overwriting the method Adapter.html#getView in your adapter: @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position,…
-
1
votes1
answer41
viewsA: Get console location and size in pixels
You can use the function GetCurrentConsoleFont, information will be returned as the numeric index of the source in console source table and the structure COORD, which shall contain the information…
-
3
votes3
answers78
viewsA: Step in a for cycle
In Javascript the index of a array starts from the 0, nay 1, so the result of your code is right. Alternatively you can do: max = 30; min =-20; step = 5; arr_text_y = []; for (var i = min; i <=…
javascriptanswered stderr 30,356 -
8
votes2
answers6238
viewsA: How to know if the file is being used by another process before trying to read
Simply put, you can work with the file in a block Try/Catch, in the event of exceptions, for example IOException, Voce checks the error code returned, if it is ERROR_SHARING_VIOLATION or…
-
9
votes2
answers129
viewsA: What is the difference between $var = Function() and Function var()?
The first is a anonymous function, while the second is only one defined function by the user. Anonymous functions are useful in situations where you need to use a return function, callback, see an…
-
1
votes2
answers1650
viewsA: Show hint when component receives focus
Another way to do this, which also works on top of events, is to create your own suggestion window with the class THintWindow as it suggests this article. Set the following variables: FActive:…
-
1
votes1
answer90
viewsA: Create new matrix with content from another matrix
This problem happens because in the method imprimeMatrizFeminina you iterate n times about the array matrizFemininaArryn, which is unnecessary, remove the third for and use the variable j as an…