Posts by Guilherme Lautert • 15,097 points
356 posts
-
43
votes3
answers9745
viewsQ: What are Javascript Promises (promises)?
I was researching about callback in Javascript when I found this question: How to really learn to use Promises (promises) in javascript? But after all : What are promises? What are they for?…
-
0
votes2
answers264
viewsA: How to concatenate columns from different tables?
Problems You have tags meta charset in the middle of your code, tags meta should stay in the head page, and you can only specify once the charset, because it means that the document follows that…
-
13
votes1
answer180
viewsQ: "this" a reliable reference?
Situation I was riding a widget when I started to analyze a possible error, because by the tests actually occurred : Testing document.getElementById('teste').addEventListener('click', function(){…
javascriptasked Guilherme Lautert 15,097 -
2
votes9
answers2096
viewsA: How to assign a function with parameters to click without executing it?
I imagine you want to do a "toggle". function callback1(param1, param2){ console.log(arguments); jQuery('#group').hide(); } function callback2(param1, param2){ console.log(arguments);…
-
2
votes1
answer709
viewsA: Extract existing value between two regular expression tags
First of all HTML is not a regular language and therefore cannot be processed by a regular expression. An appropriate tool should be used for these cases. However If you have a "regular" range in…
-
1
votes1
answer29
viewsQ: jQuery selector does not find itself
I was assembling a feature that aimed to find others selects of equal value, when I came across this situation : jQuery('select[name="group2"]').val('emissao');…
-
3
votes1
answer2544
viewsA: Select last JOIN record
What you need is a SubQuery not a LEFT JOIN. SELECT tb_processo.nm_empresa, tb_processo.dt_solicitacao, ( SELECT tb_detalhes.desc_detalhes FROM tb_detalhes WHERE tb_detalhes.id_processo =…
-
2
votes1
answer26
viewsA: .htaccess detect string after Slash
Your Regex does not contemplate what you wish. She says she can have anything but must end with /xx/. And what you want is anything + /xx/ + anything. That would be so : (.*)/xx/(.*). I personally…
-
1
votes2
answers620
viewsA: Enable TAB key for next field in Regexp
Test Like this : $('#usuario').bind('keypress', function (event){ var regex = new RegExp("^[0-9a-zA-Z \b]+$"); var keyCode = event.keyCode || event.which; // 9 é o keyCode do tab if…
-
2
votes2
answers5307
viewsQ: How to disable checkbox without using disabled?
How could I inhibit the alteration of a checkbox unused disabled, given that I want to send it via form. <input type="checkbox" name="option1" readonly="readonly" checked="checked"/> // esta…
-
4
votes3
answers4280
viewsA: Fill in the input text value via checkbox
Using the same logic as the @Carlinhos reply, but adding the option to remove: function add(_this){ var resultado = document.getElementById('resultado'); var value = _this.value; var hasAdd =…
javascriptanswered Guilherme Lautert 15,097 -
2
votes2
answers113
viewsA: How to prevent a plugin from conflicting?
For by doing this you create a local scope and any and all var or function that you create belongs solely to this site, you will have access to the global space outside, but the outer space will not…
-
1
votes3
answers801
viewsA: Replace in the javascript array
Good let’s convert the comment to practice: Luan the way you are doing this creating a monodimensional array of String, and what you want is a two-dimensional array of Int, for that you will have to…
-
3
votes3
answers2223
viewsA: How to group for weeks using sql?
Using the Function date_trunc of Postgres himself : SELECT date_trunc('week', dt_registro), SUM(vl_total) FROM tb_nota WHERE dt_registro BETWEEN '01/02/2016' AND '01/03/2016' GROUP BY 1 ORDER BY 1…
-
4
votes15
answers4487
viewsA: Determine if all digits are equal
The first thing I thought was to do for potency, however no answer did it : function checkEqual(num){ var len = num.toString().length; // VERIFICA QUANTOS CARACTERES ESTAO ENVOLVIDOS if(len == 1)…
-
1
votes1
answer150
viewsA: With breaking a Base64 string and assigning to input fields
The simplest method I believe is by REGEX. Using the match : var str = 'lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy…
-
14
votes6
answers2300
viewsA: AJAX is not a programming language. So what is it?
The Question Being More Specific: AJAX is a Recourse javascript. In which you can : Refresh the web page without reloading the page Send data to a server - after the page is already loaded.…
-
0
votes1
answer446
viewsA: Show/Hide meta characters
Using a answer I found on the internet, through a plugin: 1st Step : Tools->New Plugin... Paste the following code: import sublime, sublime_plugin class…
sublime-text-2answered Guilherme Lautert 15,097 -
0
votes1
answer446
viewsQ: Show/Hide meta characters
How I would do to with one click change the display of meta characters in the sublime?
sublime-text-2asked Guilherme Lautert 15,097 -
5
votes2
answers1259
viewsA: How to escape the percentage character (%) in the LIKE?
You need to escape it: For the tests I did on Sqlfiddle. By default the \ already is the ESCAPE, in such a way that just doing: SELECT * FROM tb_table WHERE nome_fantasia LIKE 'name\%name'; It…
-
3
votes1
answer84
viewsA: How to make a regex that accepts one line but not two?
I’m not sure I understand, but: ([^\n]*\n)([a-zA-Z]+)([^a-zA-Z]) ([^\n]*\n) take anything until you find one \n ([a-zA-Z]+) a-za-Z any quantity of at least 1 ([^a-zA-Z]) anything other than a-za-Z,…
-
3
votes2
answers236
viewsA: Do Regex.Split on what is not between "..."
I set up a different REGEX than of @gypsy, but the analysis is the same: Capture the previous group to identify the posterior comma. REGEX: (?|(['"])[^\1]+?\1(,)?|([^,])(,)) See working. The comma…
-
2
votes2
answers76
viewsA: Split arguments with regex
Assuming the pattern is arg being fixed : $str = "arg1 'arg 2' arg3 arg4"; preg_match_all("~arg\d|'arg[^']+'~", $str, $matchs); print_r($matchs[0]); If you do not want to include ' use :…
-
1
votes2
answers58
viewsA: Json return from php to jquery ui
The problem is that in your flock not all registrations should have email so generating content with value vazio. To solve this problem you can do so : $resJson = '['; $first = true; while($res =…
-
1
votes3
answers50
viewsA: comma between the arrays
$diasPromocoes = array($seg,$ter,$qua,$qui); // O array_filter com callback vai limpar os campos vazios do array $diasPromocoes = array_filter($diasPromocoes, function($item){ …
phpanswered Guilherme Lautert 15,097 -
5
votes1
answer84
viewsQ: Prevent or remedy it?
Lately I’ve been too preoccupied with preventing code errors. Yet I was left with that doubt: It is better to check (prevent) or remedy (Ensure existence)? Let’s say you did : $var = array( 'name'…
-
8
votes1
answer1984
viewsA: How to drag a div on my page?
Some time ago I developed this function : function parseNumber(num) { return parseFloat(num.replace(/[^\d]/)) || 0; } var movePopUp = (function() { var startX; var startY; var currentPopUp = null;…
-
5
votes4
answers1308
viewsA: What is the purpose of an empty parenthesis "()" in a regular expression?
Complementing the Response of the Gypsy. Group are used for information extraction or reuse. A group () empty references the nothingness that in compiler would be the same as a direct transition to…
regexanswered Guilherme Lautert 15,097 -
0
votes2
answers142
viewsA: Access multidimensional arrays of a php input
First note that in your array not the key name or tmp_name which is common when using $_FILES in PHP. This way I know you must be using the wrong method to capture the form data. (You must be using…
-
2
votes5
answers631
viewsA: str_split does not work well in string containing UTF-8?
PHP does not support all Unicode characters, however you can force them through REGEX. preg_split('//u', 'coração da programação'); u is the modifier for Unicode.…
-
0
votes1
answer526
viewsA: Capture part of a string within a pair of <> characters using regex
Try it like this : String s = "<><PALAVRA outrapalavra>palavra</PALAVRA>"; String parametro = "palavra"; String replace = "NovaPalavra"; Pattern p =…
-
10
votes4
answers1768
viewsA: What is the difference between ; and & in a URL?
In the commented link by @Bacco we have the following definition: The query string is composed of a series of field-value pairs. Within each pair, the field name and value are separated by an equals…
-
23
votes2
answers8284
viewsA: What does the REGEX shortcut mean?
The \s covers much more than the ' ' (space). \s = [ \t\n\r\f\v] ' ' (space) \t TAB \n new line (line break) \r Car reset (back the courses to the beginning of the line) \f advance page \v vertical…
-
28
votes2
answers8284
viewsQ: What does the REGEX shortcut mean?
I see a lot of people wearing \s in regex thinking its meaning is ' ' (space) because I tell you, it’s not, at least not only that. But then what does the \s in REGEX?…
-
5
votes1
answer96
viewsA: The end of a capture in a regular expression
It’s simple and you you’ve asked a question about it : Change to : '/%\[\s*(.*?)\s*\]/' The Non-greedy Operator. Addendum Caution when using the operated \s, many people use it thinking it means…
-
5
votes5
answers6065
viewsA: Get input array value
$(document).ready(function(){ var inputs = jQuery('input[name^="valor"]'); var values = []; for(var i = 0; i < inputs.length; i++){ …
-
3
votes4
answers13696
viewsA: Display message and hide in a few seconds
show a notification when entering the site and disappear after a few seconds Using the Example you gave yourself : $(document).ready(function(){ // A DIFERENÇA ESTA AQUI, EXECUTA QUANDO O DOCUMENTO…
-
0
votes2
answers513
viewsA: Database search with value of <select>
The problem with your code is that your options, are incomplete : <select class="form-control" id="inputUnidade" name="inputUnidade"> <option value="{valor que sera atribuido ao…
-
1
votes5
answers1137
viewsA: Postgresql - Remove tuple referenced by another table
He set up a function for that : CREATE LANGUAGE plpgsql; CREATE OR REPLACE FUNCTION checkDependence(VARCHAR, VARCHAR, INTEGER) RETURNS BOOLEAN AS $$ DECLARE tableName ALIAS FOR $1; columnName ALIAS…
-
4
votes1
answer49
viewsQ: What is the best way to perform a dependent addition/subtraction operation?
It is common when one is at the beginning to come across this doubt. I have to perform an operation that is dependent on a condition : Example 1 $operacao = 'somar'; $valor1 = 5; $valor2 = 10;…
-
2
votes3
answers3134
viewsA: Add or Remove Class from a DIV by clicking
Try changing to : <div id="bottaaoPA" onclick="if(this.hasClassName('select')){ this.className = ''}else{ this.className = 'select' };">ComprarPA</div> With pure JS.…
-
31
votes1
answer5487
viewsQ: What is the difference between single quote ' and double quote " in SQL?
Context When I do an SQL and wish for a specific alias I should quote between double quotes ". SELECT A.ds_nome_pessoa AS "Pessoa.nome" ... When I want to make a where in field varchar the values…
-
1
votes2
answers187
viewsA: How would a regular expression find an attribute html + attribute value?
You can make it so : data-placeholder="([a-zA-Z0-9 ]*)" Case _ no problem if it diminishes it to : data-placeholder="([\w ]*)" Explanation data-placeholder=" literal search, must contain in string.…
-
5
votes3
answers1803
viewsQ: Tables/Temporary content in the database?
Situation I am wanting to manage a process using the resources that database offer, as INSERT, UPDATE, DELETE. However all this process is temporary, that is, I have to generate tables and data that…
-
0
votes3
answers3208
viewsA: Perform two functions with onclick
You can also transcribe this function into one: function mostrar(id, show){ var show = (show) ? 'block' : 'none'; document.getElementById(id).style.display=show; } mostrar('introductionAds', true);…
javascriptanswered Guilherme Lautert 15,097 -
1
votes2
answers1756
viewsQ: C# Challenge Variable value exchange
I recently made a very simple challenge : Swap the value of two variables without using a third variable. int a = 5; int b = 3; a += b; // a = 8 b = a - b; // b = 5; a -= b; // a = 3; It is simple…
-
1
votes6
answers8595
viewsA: javascript loop with Sleep
Alternative with Settimeout() : var setTimeOut = (function(){ var callback = null; var time = null; var iterate = null; if(!!iterate) iterate = 1; if(!!time) time = 1; var k = 1; var loop =…
javascriptanswered Guilherme Lautert 15,097 -
6
votes2
answers731
viewsA: SQL - Double UPDATE with double Where
Possible is, but the syntax is terrible and I wouldn’t recommend it : UPDATE usuarios SET nome = ( CASE id WHEN 1 THEN 'Matheus Silva' WHEN 2 THEN 'Lucas Silva' END) WHERE id IN (1,2); Imagine…
-
4
votes4
answers1852
viewsA: Reference of variable
The passage by reference I believe to be one of the coolest things that has in the programming. I believe that one of the questions to be asked when studying this is : Reference to what? Memoria…
phpanswered Guilherme Lautert 15,097 -
3
votes2
answers253
viewsA: Regex - Regular Expression
The REGEX for the name test should be : `[a-zA-Z\.]+` So you guarantee only letters (not accented) and the . How much the password I recommend this question, but transcribing the part that interests…