Posts by stderr • 30,356 points
651 posts
- 
		2 votes1 answer5078 views
- 
		8 votes1 answer2411 viewsA: Block keyboard and mouse or prevent user from leaving window in C#You can use the function BlockInput, with it you will block the use of the keyboard and mouse. using System.Runtime.InteropServices; [return: MarshalAs(UnmanagedType.Bool)] [DllImport("user32.dll",… 
- 
		5 votes3 answers972 viewsA: Why are there so many ways to check if a value is NULL? How to standardize?The function is_null() does the same as NULL ===. They both do the same thing, but in terms of speed, NULL === is faster, 14 times faster (according to this comparison here). In relation to the… 
- 
		6 votes2 answers1726 viewsA: How to replace multiple using variable as first parameter?You can do it like this: var ola = "ola mundo ola mundo"; var variavel = "ola"; var re = new RegExp(variavel, 'g'); ola = ola.replace(re, 'xxx'); alert(ola); // xxx mundo xxx mundo DEMO Instead of… 
- 
		4 votes4 answers4234 viewsA: Convert Mysql date (YYYY/mm/dd h:m:s) to dd/mm/yyyyThis should work: setlocale(LC_ALL, "pt_BR", "pt_BR.iso-8859-1", "pt_BR.utf-8", "portuguese"); date_default_timezone_set('America/Sao_Paulo'); $olddata = '09/02/2015 15:55:30'; $data =… 
- 
		1 votes3 answers2792 viewsA: Lifecycle Delphi datasnap which to use?The estate LifeCycle has basically three options: Server: The server maintains a single instance of the class on the server, all clients upon requesting that class will always receive the same… 
- 
		2 votes2 answers1135 viewsA: Format Customformat value in LivebindingIf you are passing a value with floating point, do not use format %d, it is used to whole, use %m for monetary values or %n for floating point values. Your code can look like this: Format('%n',… 
- 
		2 votes1 answer838 viewsA: Android Alarm / IOS with PhonegapA plugin that can be used is the Cordova Local-Notification. The essential goal of local-Otifications is to allow an application to inform its users that it has something for them - by example, a… 
- 
		1 votes1 answer1152 viewsA: How do I update a datatable line with jquery?Use the method fnUpdate for that reason. Update a cell or table row - this method will accept a unique value to update the cell, an array of values with a element for each column or object in the… 
- 
		3 votes1 answer44 viewsA: What is the name of these instructions in Wordpress?Maybe you are looking for this page, Function Reference. See also PHP Documentation Standards.… 
- 
		3 votes3 answers8700 viewsA: Typeerror: not all Arguments converted During string formatting (Python 3.4)As already mentioned the correct is to represent these floating values with a point . and not a comma ,. Behold here the problems and limitations of floating values in Python. Your code should look… 
- 
		24 votes2 answers18486 viewsA: What is the Role attribute for?This attribute serves to give more semantics to the elements of marking-based documents, the from 2013 onwards to W3 began to recommend its use. In Portuguese Roll means Paper, in the sense of… 
- 
		59 votes3 answers204336 viewsA: What is the difference between asynchronous and synchronous communication?I will try to complement the answer from Lolipop. :) Synchronous and Asynchronous communications are two distinct methods of synchronization of transmitting, each has its advantages and… 
- 
		4 votes2 answers1998 viewsA: Open xls (password protected) file in Delphi and save data in Firebird tableThis can be done through architecture Component Object Model. The Component Object Model (COM) is a software architecture that allows applications to be built from binary software components. COM is… 
- 
		2 votes4 answers6834 viewsA: Find character in stringUse the function strpos. Its parameters are: $haystack: To string in which the search will be made. $needle: Characters to be searched. $offset: This parameter allows you to define from which… 
- 
		7 votes2 answers1527 views
- 
		1 votes1 answer1181 viewsA: Identify Visitor and User in WordpressYou must be looking to use the function is_user_logged_in(), if the user is logged in the return value is true, otherwise it is phony. if ( is_user_logged_in() ) { // Fazer algo quando esse usuário… 
- 
		19 votes4 answers8313 viewsA: Is using addslashes against SQL injection safe?There are chances to leave the system vulnerable. That one article, addslashes() Versus mysql_real_escape_string() cites a good reason for this. In free translation: If I want to attempt an SQL… 
- 
		2 votes1 answer763 viewsA: Warning: simplexml_load_string()I think you should be looking to use the function file_get_contents and not get_content. Your code should look like this: $mp3_search =… 
- 
		3 votes1 answer77 viewsA: If string starts with "www" automatically insert "https://"Are you using the denial operator !, so it doesn’t work the way you expect it to. if (!s_url.startsWith("www.")) { myWebView.loadUrl("https://" + s_url); } The second line only comes into action… 
- 
		1 votes2 answers417 viewsA: Add hours with the Final Countdown pluginIt can also be done like this: var data1 = new Date ('2015/02/16'); var data2 = new Date (data1); var addHoras = 21; data2.setHours ( data1.getHours() + addHoras); $('#clock').countdown(data2,… 
- 
		3 votes2 answers894 viewsA: Problem with SUDO "must be setuid root"This problem probably occurred after you executed the command below (source): sudo chown -R `whoami` `npm -g bin` When using the command chown with the option -R you tell the system to change the… 
- 
		1 votes2 answers266 viewsA: How to search for old files on Linux?To search for files that have a certain age, you can use the grep in conjunction with the find through the option -mtime to carry out the search. The example below will look for the word foo in all… 
- 
		1 votes1 answer1216 viewsA: Does using a token in an HTML form really protect against CSRF?Utilise tokens only makes prevention, there is a real guarantee of protection. This attack can be prevented in several ways. Using Synchronizer Token Pattern is a way that the application can rely… 
- 
		7 votes2 answers1844 viewsA: How to declare an anonymous function in Python?You can create anonymous functions in Python via an expression lambda. According to the documentation: lambda expressions have the same syntactic position as expressions. They are a shortcut to… 
- 
		2 votes1 answer642 viewsA: Picking multiple values between tagsThe function below scans a text, and checks on a loop if the current element contains the tag, if you have, add in the Stringlist. This information is obtained through the interface IHTMLDocument2.… 
- 
		3 votes2 answers5383 viewsA: How to select all characters except some specific words using regex?To remove a certain character from a sequence just make the following substitution (example in Javascript): var texto = 'xxxxxxxxboloxxxxxxxfarinhaxxxxxxacucarxxxx'; var expReg = /([x]+)/g; // Vai… 
- 
		6 votes3 answers5279 viewsA: How to check if a variable was set in Python?Another alternative way is the function dir(): Without arguments, returns a list of names of the current scope. With argument, returns a list of valid attributes for this object. See the examples… 
- 
		3 votes1 answer5815 viewsA: Changing values of a two-dimensional array - PHPYou can walk through it like this: foreach($myArray as $key => $subarray) { $myArray[$key]['interesse'] = '1'; // ... } DEMO… 
- 
		2 votes1 answer3525 viewsA: How to send/receive data using Sendmessage or Postmessage API?You are passing the data through lParam, wParam comes to the other empty process. SendMessage(HWND_BROADCAST, WM_SHUTDOWN_THREADS, 0, LongInt(@MyData)); ↑ If I understand what you want to do, you… 
- 
		4 votes1 answer135 viewsA: include bootstrap in JsfiddleTo use Bootstrap in Jsfiddle you have to include it in external resources: JS: http://netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js CSS:… 
- 
		1 votes1 answer180 viewsA: Matrix image sorting pluginI found two plugins who do what you want: Jquery Shapeshift Shapeshift is a plugin that will dynamically organize a collection of elements in a grid and column system similar to Pinterest. What the… 
- 
		2 votes1 answer532 viewsA: Sublime Text 2 update right on siteYou can use the package SFTP, for Sublime Text 2 and 3. Characteristics: Mapping a local folder to a remote folder. Upload files, folders or just the changes since your last commit. Upload all open… sublime-text-2answered stderr 30,356
- 
		1 votes3 answers656 viewsA: What is the best way to convert HTML entities with Javascript?This can also be done (code taken from mustache.js): var entityMap = { // Lista de entidades "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/":… 
- 
		3 votes1 answer60 viewsA: $. inArray() return not expectedYou are using Semicolon as delimiter(;), but what is right is a comma(,). var cookiesplit = array.split(','); The method .InArray() search for an exact value in a array, is returned -1 because there… 
- 
		1 votes1 answer3099 viewsA: PHP route system using Google Maps APIFor this you can use the Google Distance Matrix API for distance and travel time to an array of origins and destinations. This service does not return detailed route information. The Distance Matrix… 
- 
		1 votes1 answer485 views
- 
		3 votes2 answers833 viewsA: How do I know if request.FILES is empty?Like the attribute FILES of HttpRequest is a dictionary, you can check it in several ways: files = {} if not files: print "Dicionario vazio!" if not bool(files): print "Dicionario vazio!" if… 
- 
		2 votes2 answers322 viewsA: Get the highest value of an array in LuaThe code posted by you works as expected. tem_array = {10, 2, 3, 20, 1} arraymax = math.max(unpack(tem_array)) print (arraymax) -- 20 DEMO Another way is to classify the elements through the sort()… 
- 
		5 votes3 answers10914 viewsA: How to remove the first element from a list in python?The method can also be used del to remove an item by specifying its index. lista = ['foo', 'bar', 'baz'] del lista[0] print lista # ['bar', 'baz'] The difference between pop and del is that pop… 
- 
		2 votes1 answer508 viewsA: Hide div when input on Focus, cssYou can do something like this: div { background: #f0a; display: true; height: 200px; width: 200px; } input:focus + div { display: none } DEMO You can use classes or identifiers like this:… 
- 
		2 votes2 answers89 viewsA: Desktop widgets in JavaOne of the alternatives you can use to do this is the Google Web Toolkit. Google Web Toolkit is an open source Toolkit allowing developers, create applications with Ajax technology in Java… 
- 
		2 votes1 answer72 views
- 
		2 votes2 answers1803 viewsA: How to recover the number of characters via regular expression?With regular expressions it should not be possible to do this as quoted in reply of Miguel Angelo, however, through a loop you can get the amount of occurrences of the characters and store them in a… 
- 
		2 votes2 answers62 viewsA: Error in counting uppercase charactersAnother alternative using regex. $("#senha").change(function(){ var senha = $("#senha").val(); $('#teste').html(senha.replace(/[^A-Z]+/g, '').length); }); DEMO The expression [^A-Z]+ will only match… 
- 
		1 votes1 answer109 viewsA: Set default value in Textarea’s if emptyWith Jquery you can do this in the event .change, this event is triggered when the value of an element is changed. In this event it can be checked whether the textarea is empty, if it is, we put a… 
- 
		5 votes2 answers6933 viewsA: How to download a . pdf file with JSF?On a button call the method below. // Aplicável ao JSF 2.x private static final String PDF_URL = "http://.../file.pdf"; public void download() throws IOException { FacesContext facesContext =… 
- 
		6 votes2 answers4285 viewsA: Just read the first character of a stringAnother alternative is the function substr: if (substr($myrow['Noticia'], 0, 1) !== '<' && $myrow['Noticia'] !== 'Nao') { echo "Noticia mal colocada!"; } Where substr ( string $string ,… 
- 
		2 votes1 answer51 viewsA: Cmake 3.11 failed to compile REGEXMissing close parenthesis at the end of the line. string(REGEX REPLACE "^.*${FLEX_EXE_NAME_WE}(${FLEX_EXE_EXT})?\"? (version )?([0-9]+[^ ]*)( .*)?$" "\\3") In the code from Findflex.cmake that line… compilationanswered stderr 30,356
- 
		1 votes1 answer731 viewsA: Upload photo and save original photo and one cut?When saving the modified image, save the original as well: $imagem = $_FILES['arquivo']['name']; ... .. . $resize_tamanho = new resize($_UP['pasta']. $imagem);…