Posts by stderr • 30,356 points
651 posts
-
9
votes3
answers739
viewsA: Add space to each letter in UPPERCASE
To do this you can use the following regex, /(?<!\ )[A-Z]/. $str = "oiEusouMuitoLegal"; echo preg_replace('/(?<!\ )[A-Z]/', ' $0', $str); // oi Eusou Muito Legal Ideone The excerpt (?<!\ )…
-
1
votes2
answers623
viewsA: Script to find and replace words in multiple files
Sed sed -i 's#export\([A-Za-z0-9/-\_]*\)/#media/pendrive/#g' *.html To regular expression A-Za-z0-9/-\_ will match letters and digits, including characters such as bar and lower dash. Make sure you…
-
7
votes4
answers3497
viewsA: How to prevent the user to enter numbers for a given data?
One mode you can use to check whether or not a sequence contains certain characters is through regular expressions, in Java you can use the method String.Matches(), this method returns true if the…
-
3
votes2
answers690
viewsA: Avoiding two processes of the same application in Pascal
The component Uniqueinstance can do this job for you, to use it just drop a component in the main form, manipulate the property Identifier(used to identify your application) and activate it. You can…
-
9
votes3
answers1558
viewsA: Last folder of a directory
You can use the function ExtractFileName() to extract the name of a file or folder, the result will be the rightmost characters of the string passed as parameter, starting with the first character…
-
2
votes2
answers322
viewsA: How to access menu item from a menu
You can use the method Menu.add_command to link a function to an item in the Menu: # -*- coding: utf-8 -*- from tkinter import * def foo(): print ("Foo bar") root = Tk() menubar = Menu(root)…
-
6
votes2
answers12692
viewsA: Find out if item is in array
If you use recent versions of Delphi(D2010.. XE), there is the function MatchStr that can do this work for you. However, if you use older versions of Delphi(D6, D7) the function is used…
-
0
votes1
answer429
viewsA: Control whether a Tkinter. Text is empty
Try the following: if text_area.get(1.0, tkinter.END) != "": print("Text não vazio") 1.0 Means line 1, spine 0, lines are indexed from 1 and columns are indexed in 0. At the following link(Text…
-
1
votes2
answers436
viewsA: Error compiling in Delphi XE5 UPD2
It seems you have made a custom installation of Delphi XE5, when trying to install XE6 version you must have opted for a default installation that must have changed the current (custom) settings, a…
-
5
votes1
answer987
viewsA: ORA-00911: invalid Character
According to what’s written here(GUJ) the problem is probably the semicolon at the end of the sql. string sql_work = "select w.login , w.data, sum(w.work_time) work_time"; sql_work += " from…
-
5
votes4
answers844
viewsA: rtrim() to remove "<br>" also removes the letter "r" if it is the last letter in the string
You can in a loop/loop check the position of the characters to be removed from the string by using strpos() and "cut off" the string with the function substr(). You can implement this as follows:…
-
4
votes2
answers35240
viewsA: How to develop programs for Android through Python?
Another alternative is the QPython that allows you to create and execute scripts on Android, it comes with a development kit that contains: Console: A console for regular Python, feel free to…
-
4
votes1
answer1251
viewsA: How to read Querystring parameters in Javascript
function getUrlParameters(parameter, staticURL, decode){ /* Function: getUrlParameters Descrição: Obtem o valor dos parâmetros da URL atual ou URL estática Author: Tirumal URL: www.code-tricks.com…
-
3
votes3
answers533
viewsA: Difficulty with web scraping
You can do this in many ways, as mentioned by mgibsonbr, to extract a piece of a string the use of regular expressions is commonly used for this purpose, such as manipulate the string. Assuming we…
-
1
votes2
answers2239
viewsA: Variable result with IDHTTP
It is possible yes. Just use the method Get of IdHttp, thus: procedure TForm1.Button1Click(Sender: TObject); Const LINK = 'http://www.xxx.com.br/teste.php?Teste'; begin IdHTTP1.HandleRedirects :=…
-
1
votes1
answer388
viewsA: User Choices in Tkinter
The widget Button provides a callback which allows you to do something when the user clicks the button. Take an example: from Tkinter import * def callback(): print "O usuario clicou no botao" b =…
-
0
votes3
answers944
viewsA: PHP and Sqlserver connection
According to the job documentation mssql_select_db one likely cause of this error may be the underscore contained in the name of the database. To escape the name of a database that contains spaces,…
-
1
votes1
answer186
viewsA: Reload/Wininet Cache Flag
You can use the flag INTERNET_FLAG_RELOAD to do this. Use this flag when calling the function InternetOpenUrl. In your case it would look something like this. SessaoHandle := InternetOpen(nil,…
-
1
votes1
answer130
viewsA: Is working with 'Weights' viable?
That’s bad because the layout_weight requires that the widget is measured twice when a LinearLayout with Weight other than zero is nestled in another LinearLayout with Weight also different from…
-
6
votes2
answers5374
viewsA: How and when to use exceptions in PHP?
When to use exceptions? You use an exception to indicate an exceptional condition, that is, something that prevents a method from satisfying its purpose and which should not have occurred at that…
-
6
votes3
answers23020
viewsA: How to initialize postgresql with Ubuntu?
You probably didn’t put the postgresql to start in the boot. On the terminal run the command: sudo update-rc.d postgresql defaults For more information see update-rc.d(8).…
-
1
votes2
answers860
viewsA: Last position of a string
With the use of regular expressions one can do this: var txt = "Foo Bar Estoque1 Baz Poo Par Paz..."; txt = txt.replace(/Estoque1(.*)/, "Estoque Vencido"); // => Foo Bar Estoque Vencido The…
-
24
votes5
answers26646
viewsA: Is there a "sudo" for Windows?
The tool runas Windows is equivalent to sudo of Unix/Linux. Your syntax is: runas [/profile | /noprofile] [/env] [/netonly | /savecred] [/showtrustlevels] [/trustlevel] /user:<UserName>…
-
2
votes4
answers5635
viewsA: Make a regex to remove characters
With regular expressions one can do so: var resultado = "/Date(1401731794773)/" data = resultado.match(/[\d]+/); console.log(data); // 1401731794773 The expression /[\d]+/ will make it only captured…
-
2
votes1
answer89
viewsA: Number inside a file can be the number inside the.Leep team?
In the code presented by you the function ler_tempo_boot() returns the duration in seconds to be used in the time.sleep(). try: temp = int(ler_tempo_boot()) time.sleep(temp) except ValueError: # Não…
-
7
votes3
answers34998
viewsA: Timer in Python
Use the method time.sleep(). import time def tempo(): time.sleep(10) print "Ola" To make a stopwatch and print the number on the same line: import time, sys for i in range(0, 10):…
-
1
votes1
answer33
viewsA: Error:Build Solution - Visual Studion
Something deleted the file shortly after it was created, usually this behavior is presented by Antivirus that detected the file as a threat.
-
0
votes2
answers739
viewsA: How do I give the user permission to access a page in the Yii framework?
This error is certainly caused by IP filtering mechanism that Gii use to protect the system against intruders, by default only access is allowed in localhost, to remote users(which apparently…
-
1
votes1
answer5312
viewsA: C# Socket Refusing Public Connection
Reply given in comment: The problem was caused because the OP has a service(VNC Viewer) starting along with Windows using that same port, the port has been changed and connected in an expected way.…
-
2
votes1
answer840
viewsA: How to edit text
In the following passage: if avanced == "Alterar a forma de inicialização": alterar = raw_input("O que deseja alterar: \nApresentação inicial da VM, \nApresentar código de arranque, \nEditar…
-
1
votes1
answer836
viewsA: Error writing text file: cannot Convert Std::string to const char*
The functions fprintf and fputs accept the type const char *, you are passing a variable std::string. Use c_str() to use the variable as C-string: // ... fputs(aux2.c_str(), arquivo); // ...…
-
2
votes1
answer828
viewsA: Global variable is not defined
Declare the variable texto out of function. texto = "" def editor(): global texto texto = raw_input("digite o texto que quer que o menu principal imprima:") def arranque(): print "%s" %(texto)…
-
2
votes2
answers3742
viewsA: How to check if Internet Explorer is smaller than version 10?
Another way is to check the existence of some objects and combine some checks. The following table contains the ready-to-use conditions. Versões do IE Verificar condição 10+ document.all 9+…
-
2
votes2
answers1063
viewsA: Send CTRL+V via Postmessage
You can do this by sending the message WM_PASTE to the Handle out the window like this: var appHandle: HWND; begin appHandle := FindWindow(nil, 'TitulodaJanela'); if appHandle = 0 then // Se não…
-
1
votes1
answer815
viewsA: Check uploaded image
Yes. Assuming the image you will upload is from the internet, you can do so: Var imageURL: string; MS: TMemoryStream; Jpg: TJPEGImage; begin imageURL := 'URL da imagem aqui'; try MS :=…
-
2
votes1
answer460
viewsA: How to save user changes
You can create a function that writes changes to a file: def salvarAlteracao(arquivo, texto): with open(arquivo, 'r+') as f: f.write(texto) f.close() The r+ is to open the file to reading and…
-
27
votes5
answers12967
viewsA: Why is the use of GOTO considered bad?
Original image: xkcd 292 It is rare to find situations where you need to use it, but I would not completely discard its use. Although the use of goto almost always is bad programming practice (sure…
-
3
votes2
answers1330
viewsA: How to insert a variable in the middle of the address I pass to Urllib2?
There are some ways to do this. Operator modulo %: id_User = "IdUserNameAqui" request =…
-
3
votes3
answers621
viewsA: Service to resize uploaded images to a Wordpress site
Two good online tools that do this is the Quick Thumbnail and Resizeimageonline.…
-
9
votes1
answer3212
viewsA: Delphi, Tthread.Que. What is it? When should it be used?
procedure Queue(AMethod: TThreadMethod); overload; procedure Queue(AThreadProc: TThreadProcedure); overload; class procedure Queue(AThread: TThread; AMethod: TThreadMethod); overload; class…
-
2
votes2
answers291
viewsA: Error when instantiating an object
The exception NullPointerException is launched when the program tries to use the reference of an object with null value. See an example: public static void main (String[] args) throws…
-
2
votes4
answers2351
viewsA: Merge word docx documents from a template and replace words
Example using the library DocX. static void Main(string[] args) { string templatePath = @"D:\\template.docx"; string newFile = @"D:\\newDoc.docx"; var template = new FileStream(templatePath,…
-
47
votes3
answers12057
viewsA: Differences between localStorage Vs sessionStorage?
Both localStorage and sessionStorage extend to Storage. There is no difference between them except for the nonpersistence of sessionStorage. To nonpersistence as described above is in the sense that…
-
2
votes1
answer803
viewsA: Install Plugin in Netbeans
According to the nbandroid wiki the address current and correct to install the plugins is: http://nbandroid.org/release72/updates/updates.xml This will probably solve the problem.…
-
17
votes2
answers378
viewsA: Performance in creating strings in Java
In the first case it is always the same object being recovered from String Constant Pool in the latter case, a new object is being created. String str = new String("foo"); You force the creation of…
-
4
votes4
answers4583
viewsA: Check for image return via Javascript
You can make a request HEAD and check the return status of url. function checkStatus(imageUrl) { var http = jQuery.ajax( { type:"HEAD", url: imageUrl, async: false }) return http.status; } And use…
-
1
votes1
answer147
viewsA: Error posting to a facebook fanpage using php
The problem is that whatever the url you are hosting your application is not configured in your application configuration. Go to the app settings(https://developers.facebook.com/apps) and ensure…
-
2
votes1
answer721
viewsA: String to double C++ conversion
See if it’s something like this you’re looking for. #include <sstream> #include <iostream> double resultado(std::string valor) { std::istringstream iss(valor); int X, Y; iss >> X…
-
1
votes3
answers5189
viewsA: How to pass editText value to attribute to int type on Android?
Use Integer.html#parseInt: objEquipamento.setMarcaModelo(Integer.ParseInt(edtMarcaModelo.getText().toString().trim())); If Integer.html#parseInt cannot perform the conversion, an exception…
-
4
votes1
answer879
viewsA: Atom Text Editor Installation
Both. Node.js is necessary for Atom to be executed correctly.