Posts by stderr • 30,356 points
651 posts
- 
		1 votes1 answer243 viewsA: Error with Php and Preg_matchIs probably a bug in the library version PCRE that you use, upgrade to the latest version. As can be seen in changelog, item 32: Error messages for syntax errors following \g and \k Were Giving… 
- 
		0 votes3 answers431 views
- 
		3 votes1 answer1030 viewsA: PHP Error Built in Server Invalid request (Unexpected EOF)This seems to be an old PHP flaw, as can be seen here. It’s just a warning message, it’s not something that will compromise the integrity of the application. Invalid request (Unexpected EOF) The… 
- 
		0 votes1 answer1338 viewsA: Comparing lines from a file with data from a spreadsheetI want the program to do the following: If in the file line you have what is in the column I’m going through: do the instruction else: jump to the next line. To move to the next iteration you can… 
- 
		1 votes2 answers2187 viewsA: How to capture a dbgrid Row click event?Another alternative is to use the event OnCellClick, it is fired when the user clicks on some cell of the grid. Take an example: procedure TForm1.DBGrid1CellClick(Column: TColumn); var ID: integer;… 
- 
		3 votes1 answer210 viewsA: How to close a "folder"There are several ways to do this, one of them is to use the function FindWindow to return the window identifier through the class or title name. To close, you can use the function SendMessage and… 
- 
		3 votes3 answers89 viewsA: Error calling a secondary method via CALLBACK: Uncaught Typeerror: Cannot read Property 'secondarily named' of UndefinedThis problem occurs because the function metodoPrincipal loses the reference of the object. One way to solve this is to pass the object through the bind:… 
- 
		4 votes1 answer421 viewsA: Trigger an event after two clicks on buttonThere is, the method bind, you can inform the event, which can be: <Button-1>: A click. <Double-Button-1>: Two clicks. <Triple-Button-1>: Three clicks. Among others... Take an… 
- 
		1 votes4 answers8575 viewsA: How to take system time and save in a variable?You can use the function time to return the current date and time information and localtime to represent values according to local time zone. #include <iostream> #include <ctime> using… 
- 
		6 votes2 answers2780 viewsA: How to show a separate number per point every 3 houses?One option is the method Number.toLocaleString: function formatarValor(valor) { return valor.toLocaleString('pt-BR'); } console.log(formatarValor(42000)); console.log(formatarValor(150000));… javascriptanswered stderr 30,356
- 
		3 votes2 answers267 viewsA: How to split a number stored in a string and check if it is divisible by 495?Why don’t you use class BigInteger to deal with these numbers? You can use the function BigInteger#mod: public static boolean divisivel(BigInteger numero, String divisor) { return numero.mod(new… 
- 
		2 votes2 answers46 viewsA: How to prevent a commandMaybe the lines below are not necessary because it is in the condition of both radiobutton are not marked. clnFuncionario Sexo = new clnFuncionario(); Sexo.nome = txtNome.Text; if… 
- 
		1 votes2 answers164 viewsA: Doubt about PHP command to write inside another. php fileAccording to the function documentation rewind: If you opened file in mode append (a or a+), whichever information you write to the file will always be added, disregarding the position in the file.… 
- 
		3 votes2 answers7992 views
- 
		13 votes3 answers1883 viewsA: How to Create and read ". conf" files in C, for linux environment?The extent of a configuration file is not limited to .conf, can also be .cnf, .conf, .cfg, or .ini for example. There is no pattern of how a configuration file can be called. It is possible to read… 
- 
		1 votes2 answers2629 viewsA: Code::Blocks - error: Stray ' 240'Like mentioned by José, somewhere in your code there are unexpected characters, assuming you are using Unicode or ISO-8859-1, \240 can represent the character non-breaking space (blank space that… 
- 
		2 votes3 answers2939 viewsA: Identify repeated numeric characters in sequenceYou can use the expression (\d)\1{8}. Where: (\d): Capture group, only digits 0-9. \1{8}: Refers to the first capture group. It will match the same pattern matched by the capture group eight times.… 
- 
		1 votes1 answer1789 viewsA: Validate characters only with letters and spaces (including accents)The function ctype_alpha only checks if the characters are in the range A-Za-z. One option is to use preg_match with the expression [\pL\s]+ to correspond only to letters and spaces. function… 
- 
		1 votes2 answers176 viewsA: Generate autoincrement serial number sequenceAccording to the error message, cursor.fetchall returns a list of tuples, soon the concatenation you want to do is not possible. Like mentioned by Otto, you can use cursor.lastrowid to return the… 
- 
		1 votes1 answer68 viewsA: Preg_match_all, get input name attribute valuesAs mentioned in comment, you can in addition to regular expressions, use DOMDocument to represent HTML and get its values. Assuming you have the following HTML: <form method="post" action="">… 
- 
		0 votes2 answers109 viewsA: Searching in array using more than one wordAnother alternative is the function array_diff, you can implement it like this (credits): function in_array_all($needles, $haystack) { return !array_diff($needles, $haystack); } The array_diff… 
- 
		1 votes1 answer2994 viewsA: Return the position of a word in a stringIn your code the word and the line number is already returned, to return also the position of the word in the line, use the str.index: pos = line.split().index(keyword) The str.split will separate… 
- 
		2 votes1 answer225 viewsA: Save user input to a loopMy question is how to store the generated list of this array. On the line numeros[i] = ... If I understand correctly, you already do this, keep in the array what is typed in the entry that can be… 
- 
		0 votes1 answer1014 viewsA: Resultset first does not workSqlexception: Invalid operation to forward result set only: first This happens because by default the ResultSet is not upgradable, and the cursor Just go, don’t go back. If you don’t pass arguments… 
- 
		0 votes2 answers183 viewsA: Batch file anchoredYou can use the command pushd to change the working directory, pass %~dp0 to indicate the file directory .bat, see an example: @echo off echo Diretorio atual %cd% echo Diretorio do script %~dp0 REM… 
- 
		2 votes2 answers743 viewsA: Read file and search wordYou can use the methods Array#each_index and Array#select: values = [ "a", "b", "c", "a", "d" ] p values.each_index.select { |i| values[i] == 'a' } #=> [0, 3] Another alternative is to iterate on… 
- 
		0 votes1 answer556 viewsA: Change lag and height of Excel cell using xlwtYou can set the width and height of a particular row or column using the properties width and height leaf. Take an example: # -*- coding: utf-8 -*- import xlwt book = xlwt.Workbook(encoding =… 
- 
		4 votes4 answers7723 viewsA: Check for number in a stringBelow are some other alternatives. filter_var You can use the function filter_var to filter only numbers (and + and -) using the filter FILTER_SANITIZE_NUMBER_INT, if filtering fails, the result is… 
- 
		3 votes1 answer340 viewsA: Import Mysql data to ExceldadosUser = cursor.fetchall() # ... for i,user in enumerate(dadosUser()): # ... You’re trying to use dadosUser() as a function, dadosUser contains a list of tuples or an empty list according to… 
- 
		2 votes1 answer4176 viewsA: Alignment with string.format and UnicodePython 2.x, use the prefix u to represent the string as Unicode: >>> print '{:>6}'.format('agua') agua >>> print u'{:>6}'.format(u'água') água >>>… 
- 
		1 votes2 answers1365 viewsA: How to add the result that is inside the Split function in python?Use the sum: data = ['6', '5'] print (sum(int(numero) for numero in data if numero.isdigit())) # 11… 
- 
		3 votes2 answers228 viewsA: Replace all characters with "_" except the 1° character of each wordAnother alternative is to use the String.replace together with the regular expression /\B\w/g: var valor = 'stack overflow em portugues'; var substituto = valor.replace(/\B\w/g, '_'); // s____… javascriptanswered stderr 30,356
- 
		3 votes3 answers885 viewsA: How can I check if the last position of the array has been filled?Another alternative is to get the value per index, using the count to get the total of elements and subtract by 1: $array = ['foo', 'bar', 'baz']; if (($indice = count($array)) > 0) { // Se for… 
- 
		2 votes1 answer126 viewsA: Webdriver error in Python3.5 Attributeerror: can’t set attribute>>> driver = webdriver.Firefox() >>> driver.page_source = driver.get(strg) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: can't… 
- 
		3 votes2 answers2294 viewsA: Scraping in Python - read pdfAnother alternative is to use str.encode with encoding Latin 1 and str.decode to decode to UTF-8. See an example: print ("\xc3\xb3".encode('latin1').decode('utf-8')) # ó In your case, do so: print… 
- 
		1 votes4 answers539 viewsA: Pick up word in the middle of a textYou can use the function simplexml_load_string: $html = '<a href="uploads/tutorial1.pdf">tutorial1.pdf</a>'; $xml = simplexml_load_string($html); echo $xml; // tutorial1.pdf echo… 
- 
		9 votes1 answer3291 viewsA: How to list all files in a folder using Python?There are some forms, one of them is the function os.listdir: from os import listdir def encontrar_arq(cadena, caminho): encontrado = False lista_arq = listdir(caminho) for arquivo in lista_arq: #… 
- 
		1 votes1 answer1334 viewsA: How to print a function in Python?The function ano_covertido is not running, and it also does not return any result. ano_covertido must look something like this: def ano_covertido(ano): # Pega o ano do dia atual ano_atual =… 
- 
		3 votes1 answer860 viewsA: How to send multiple requests at the same timeAsynchronously? If so, one way to do this is to use the grequests to make the requests. To install, in the terminal type: pip install grequests You can use it so (adapted from documentation): # -*-… 
- 
		2 votes1 answer862 viewsA: Why does isset not work well with $_POST?The isset checks if a variable has been defined/initialized, it is not checked if it has a value. The isset will always return true for $_POST because it will always be set, but it may be empty,… 
- 
		5 votes1 answer1821 viewsA: Extract index for repeated elements in Python listsYou can use the enumerate to iterate over the list and get the index of the repeated elements: >>> lista = ['c', 'a', 's', 'a'] >>> [i for i, item in enumerate(lista) if item ==… 
- 
		2 votes3 answers1209 viewsA: Extract numbers from a list using RegexYou can do this with the map: lista = [u'1', u'2', u'3', u'4', u'7'] outraLista = list(map(int, lista)) print (outraLista) # [1, 2, 3, 4, 7] Or use int to return an entire object: lista = [u'1',… 
- 
		4 votes1 answer146 viewsA: Why does it loop infinitely in the println?Like mentioned by Maniero, the variable valor never changes inside the loop, the condition is never satisfied. Update valor at each iteration. To get a char from the entrance, you can do so: char… 
- 
		1 votes3 answers6527 viewsA: How to release port 80 to Apache?You are running the IIS, to interrupt it, in the cmd.exe do: net stop w3svc This will disable the World Wide Web Publishing Service. More information Done this, probably the door 80 will be free to… 
- 
		4 votes2 answers437 viewsA: Hide error messagesRedirect error output to /dev/null: ping 8.asd.8.8 -c1 -q 2>/dev/null if [ $? == 0 ] then echo 'ok' else echo 'erro' fi More information: What is and what is it for "2>&1"?… 
- 
		3 votes2 answers297 viewsA: List Comprehension for this caseTo check if the current iteration item is a whole, and an even or equal number a do: l = [item for item in lista if type(item) is int and item % 2 == 0 or item == a] Take an example: lista = [1, 2,… 
- 
		5 votes1 answer77 viewsA: List being modified without implementationThe problem occurs in the section below: lista_inicial = [[1, 2], [0, 2], [0, 1]] lista_aux = [] lista_aux = lista_inicial # Aqui! In doing lista_aux = lista_inicial you are indicating that… 
- 
		3 votes2 answers116 viewsA: Add number in each row in c#To open the file for reading you can use the method File.OpenText. The File.OpenText returns a StreamReader, whereas it is a file with many lines, use the method StreamReader.ReadLine to read line… 
- 
		10 votes2 answers708 viewsA: How do I use nested repetitions to make this example?You can use the String.repeat to repeat a sequence according to the current iteration of loop: for (var contagem = 1; contagem < 11; contagem++) { console.log("*".repeat(contagem)); } To do the… 
- 
		7 votes2 answers427 viewsA: Problems with str_pad function and accentuationThis is because ã is a character multi-byte, see: echo strlen("a"); // 1 echo strlen("ã"); // 2 The function str_pad interprets ã as a character of two bytes instead of a multi-byte, to circumvent…