Posts by Guilherme Lautert • 15,097 points
356 posts
-
3
votes2
answers1532
viewsA: Capture text between two known characters
Solution in Regex: With {} Regex r = new Regex(@"\{[^\}]+?\}"); Match m = r.Match(text); Without {}: Regex r = new Regex(@"(?<=\{)[^\}]+?(?=\})"); Match m = r.Match(text); See on .netFiddle…
-
3
votes2
answers263
viewsQ: How to prevent my site from being rendered in an iframe
The idea is simple, I have a website, as I prevent another site from calling mine through a iframe?
iframeasked Guilherme Lautert 15,097 -
2
votes2
answers764
viewsA: How to query data from a table using INNER JOIN in a sub-query in PHP
I don’t know exactly what table structure you have but let’s assume it’s this tb_usuario - id_usuario - nome - foto tb_chat - id_chat - id_usuario - tx_msg - dt_envio id_user being rigid and…
-
2
votes2
answers1051
viewsA: Pass video url into Modal - Jquery
Following the documentation available on W3schools : A built-in flash animation That is to say I believe <embed> file support only .swf local. About videos from Youtube The solution I found…
-
1
votes3
answers786
viewsA: How to take several arrays with 1 single index and put in a single array?
I wouldn’t do it like this, but giving you an alternative would be : <?php function buscarEstados1($id, &$arr = array()){ include 'includes/conexao.php'; $s_down = "select id from…
-
3
votes1
answer355
viewsA: Checking browser and version with REGEX
Following this link to obtain the information : C# System.Web.HttpBrowserCapabilities browser = Request.Browser; string pattern = @"ie|internet explorer|chrome"; MatchCollection matches =…
-
0
votes2
answers27
viewsA: Reallocate line to a certain position of another line
The solution I developed was to REGEX Adjustment {1} ds_ind_exig_iss {2} ds_ind_exig_icms {3} ds_ind_exig_impressao_documento {4} ds_ind_exig_utilizacao_documento {5}…
scriptanswered Guilherme Lautert 15,097 -
-3
votes2
answers27
viewsQ: Reallocate line to a certain position of another line
Situation I was riding a script in which I knew there should be 17 fields, but I still didn’t know with these they would call, after I was defining them in the comments, in such a way that it stayed…
scriptasked Guilherme Lautert 15,097 -
2
votes2
answers604
viewsA: Relationship on-to-one in auxiliary table using Laravel
Initial consideration Programming must adapt to the bank, not the bank to programming, certainly the bank is more constant than programming, because it involves analysis, and is usually 'modeled' by…
-
6
votes1
answer694
viewsQ: How to pick up attribute dynamically
How I would make the following PHP code in C#? class teste{ public $x = 10; public $y = 10; } $n = new teste(); $a = "y"; print_r($n->{$a}); Note that dynamism is in the variable $a, in which if…
-
0
votes2
answers577
viewsA: Validate Field with Avascript
I managed an extension in jQuery, whether it helps. Note that both on Blur as in the Submit it validates the fields var validForm = false; (function (jQuery){ jQuery.fn.validate =…
-
0
votes2
answers1528
viewsA: How to create validation with special characters
From the analysis I made of your need, using the ascii table, and the attack command for hexadecimal \x## you can reduce your regex to simply : ^([\x21-\x7E]{6,40})$ That will encompass all your…
-
0
votes2
answers207
viewsA: Regular expression start, end
What could be done too, and is much practiced by beginners is: Shapes the different REGEX /^abc.*_20150430\.txt$/ /^def.*_20150430\.txt$/ unite them by or ^abc.*_20150430\.txt$|^def.*_20150430\.txt$…
-
3
votes1
answer263
viewsQ: SPED - Block K - Record 0220
Situation I’m developing the Block K(valid as of 2016) SPED EFD, and I’m having trouble validating apart from unit conversion. Test structure |0190|CX|CX.| |0190|UN|UN.| |0190|PC|PC.|…
-
1
votes3
answers7687
viewsA: Delete duplicate record from table in Postgresql
Solution DELETE FROM tb_kardex WHERE cd_kardex IN ( SELECT cd_kardex FROM ( SELECT cd_kardex, ROW_NUMBER() OVER (PARTITION BY cd_item ORDER BY cd_kardex asc) AS rn -- CRIA UM CONTAGEM DE PARA CADA…
-
2
votes3
answers7687
viewsQ: Delete duplicate record from table in Postgresql
Situation Currently I performed a process twice in which it should be processed only once. So my table was populated twice with the same data. tb_kardex cd_kardex | cd_item tb_kardex | 1 | 45875 | |…
-
3
votes2
answers1694
viewsQ: What is the ">" CSS operator for?
In some css see the operator ">" : #panel_conteiner > p { color:red; } #panel_conteiner div{ padding:5px; margin:2px; } <div id="panel_conteiner"> <p> teste teste </p>…
cssasked Guilherme Lautert 15,097 -
7
votes1
answer5885
viewsQ: What are INDEX, B-Tree, hash, Gist, and GIN?
In the the Postgresql Manual has the following excerpt : Postgresql provides the index methods B-Tree, hash, Gist, and GIN. Postgresql provides the B-Tree, hash, Gist and GIN index methods. But…
-
1
votes2
answers1691
viewsA: How to make a Function wait for jQuery loaded with the async tag
Create a callback Seven in your file to variable as true Use setInterval to create a check continue by variable File1.js var pronto = false; function callback(){ if(pronto == true){ // ... codigo…
-
14
votes1
answer356
viewsQ: How to release frozen/locked thread?
Studying on JS: Javascript - Thread, Asymchronism, Ticks How asynchronous programming works in Javascript? There is only one thread to execute your code, you need to avoid as much as possible that…
-
1
votes3
answers1977
viewsA: How to attach events to dynamically created elements and pass parameters?
Utilizing everything you already have just by performing the .on dynamic by id: $('a[id^="detalhe-nota-"]').on('click', function(){ var id = $(this).attr('id'); var numberId = id.replace(/\D/i, '');…
-
2
votes3
answers1160
viewsA: How to set number of times the setInterval will be executed?
In function form: function setIntervalLimit(func, time, limit){ var n = 0; // CRIA UM CONTADOR INTERNO var f = function(){ // CRIA UM FUNCAO INTERNA func(); n++; if(n < limit){ // VEFIFICA…
-
13
votes3
answers1124
viewsQ: Javascript Access Modifiers
Situation function x(){ var f = null; // PROPRIEDADE PRIVADA DE x this.a = null; // AS INSTANCIAS DE x TERÃO ACESSO A PROPRIEDADE a x.b = null; // ACESSIVEL COMO x.a } function y(){ x.call(this); //…
-
20
votes1
answer1007
viewsQ: What programming languages support Linux and Windows?
The question is already in the title, however to make it clearer: What languages I write a single code in, and run on both Linux and Windows? Example C. Except some commands like system("cls");…
-
1
votes2
answers545
viewsA: Find string inside a php tag
Javascript : var arraySrc = new Array(); jQuery('iframe').each(function(){ var src = jQuery(this).attr('src'); arraySrc.push(src); }); In PHP : $strHtml = <<<EOD <iframe width="420"…
-
4
votes1
answer53
viewsA: How to capture the value of the current attribute with jQuery?
* for all elements. $('*') If you want to make a list of elements separated by ,: $('input,select,textarea') You can also use the filter : jQuery('*').filter(function(){ var accept = [ 'input',…
-
3
votes1
answer546
viewsA: Questions about Recursion in the Mergesort function [C]
I think the best way to explain this is by a graph: Mergesort void MergeSort (int *V, int inicio, int fim) { if (inicio < fim){ int meio; meio = floor ((inicio + fim) /2); MergeSort (V, inicio,…
-
0
votes2
answers9874
viewsA: PHP variable in an HTML value
In the first <td> you didn’t put the tags of PHP. In the following <td> you did but this using an array and the string interpreter tries to capture only the var in such a way that I…
-
11
votes7
answers1690
viewsA: Hexadecimal for RGB
In PHP I withdrew the answer from here: function hex2rgb($hex){ $hex = str_replace("#", "", $hex); if(strlen($hex) == 3) { $r = hexdec(substr($hex,0,1).substr($hex,0,1)); $g =…
-
15
votes7
answers1690
viewsQ: Hexadecimal for RGB
How to convert a Hexadecimal color (#FFFFFF) for RGB (Red, GReen, BLue)? Example
-
3
votes5
answers267
viewsA: Store arithmetic operator in variable
I would implement it as follows : $value1 = 10; $operador = '+'; $value2 = ($operador === '+') ? 10 : -10; $value2 = $value1 + $value2; or $value1 = 10; $value2 = 10; $operador = '+'; if($operador…
-
9
votes3
answers432
viewsQ: Javascript - Thread, Asymchronism, Ticks
Situation Studying on Thread, I understood that they are lines of execution within a process. Studying on Assincronismo em javascript, I understood that it does not support multiple Thread, but has…
-
8
votes6
answers1359
viewsA: How to insert an if/Else into an echo?
Utilize sprintf and ternario Code $dadoBanco = 1; $option = '<option value="%s" %s>%s</option>'; $selected = 'selected="selected"'; echo sprintf($option, 0, ($dadoBanco == 0) ? $selected…
phpanswered Guilherme Lautert 15,097 -
0
votes5
answers1057
viewsA: Problem with in_array()
Two problems: You’re trying to check a chave whereas the in_array search for values. You have a array two-dimensional, and it’s trying to verify the innermost content. Possible solutions foreach…
-
1
votes2
answers40
viewsA: PHP variables with wrong values after string manipulation
I think it would be easier to do preg_match, bearing in mind that you have a string well-defined. $respostaXML = "<data-hora>2015-11-10T11:33:41.086-02:00</data-hora>"; $regex =…
phpanswered Guilherme Lautert 15,097 -
5
votes2
answers393
viewsQ: Firefox claims code after Return
Situation It was performing some maintenance functions on JS. And a certain function I placed a return in the midst of it, for the rest was no longer necessary. On seeing from the comment the rest…
-
1
votes1
answer46
viewsA: Same numbers in the key-value pair of an array, but random
My development was as follows : $array = array(10,11,12,13,14,15,16,17,18,19,20); if(count($array) > 1){ do{ $flip = array_flip($array); $newArray = array(); $reset = false; foreach ($flip as…
-
4
votes2
answers986
viewsQ: regular expression replacement - reference followed by number
Situation I was performing a replace of some data when I came across a peculiarity. |C405|01102015|7|1058|174544|19836903,14|18657,06| |C405|02102015|2|1059|174792|19859872,19|22441,55|…
regexasked Guilherme Lautert 15,097 -
1
votes2
answers688
viewsA: Difference of days javascript considering dates in different months
I set up this function based on research. I think it’s better than using a library, because then you go straight to the point you don’t carry extra resources, however it is a restrictive tando, you…
javascriptanswered Guilherme Lautert 15,097 -
2
votes2
answers58
viewsA: Transform the text of a variable into an array
What you basically have a string is a pattern X-Inquiry-. The function preg_match_all search for all patterns present in the string, according to the regex passed.…
phpanswered Guilherme Lautert 15,097 -
1
votes1
answer128
viewsA: Data - date_trunc for PHP
Resolution Auxiliary Functions // REMOVE TUDO QUE NAO SEJA NUMERO, DA STRING function onlyNumber($var){ return preg_replace('/\D/', '', $var); } // AJUSTA OS NUMEROS A MASK PASSADA function…
-
1
votes1
answer128
viewsQ: Data - date_trunc for PHP
Postgresql has a date function called date_trunc How can I play it in PHP? I only need the options: cond minute hour day week Month Quarter year…
-
1
votes6
answers886
viewsA: Regular expression to grab the background-image url
Regex /url\(['"][^'"]+['"]\)/g Pluguin (function($){ $.fn.getUrlBackground = function(){ var url = []; jQuery(this).each(function(){ url[url.length] =…
-
14
votes2
answers1423
viewsQ: Javascript - Access variable
Situation I am deepening my study a Javascript, and I came up with a little doubt. In closure, encapsulation and variable scope, all show how to use the var and talk about Local and Global scope,…
-
1
votes3
answers94
viewsA: How to stick with just one part of the string?
I do not know what purpose you have with this, but already leaving in a way that opens several possibility to work. Code preg_match_all("~(id\w+)-(\d+)~", $str, $matches); $matches[1]; // ARRAY DE…
-
3
votes1
answer62
viewsA: Validate method name by suggesting the correct one
Magic Methods This must be an implementation of the magic method __call. __call() is triggered when inaccessible methods are invoked on an object. Example class MyClass{ private $methods = array(…
-
3
votes1
answer83
viewsA: Select input with id != value
I know two ways to do this: $('#minhaDiv input[id!="meuId1"][id!="meuId8"]'); or $('#minhaDiv input').filter(function(){ var id = jQuery(this).attr('id'); var idInvalidos = [ 'meuId1', 'meuId8', ];…
-
20
votes5
answers1499
viewsA: What is a gluttonous regular expression?
Quantifiers Specify how many times the previous instance should be captured Quantifier Greedy In general when talking about greedy quantifier refers to the *, because it represents 0 or infinite…
regexanswered Guilherme Lautert 15,097 -
4
votes3
answers105
viewsA: Automatic scroll to the right
Answer presented in the OS Transcription scrollLeft is scrollRight. What it does is horizontal scrolling. If you set it to 0 then it will totally go left. If you set it to > that 0 then it will…
-
10
votes6
answers9431
viewsA: When should var be used in Javascript?
I believe that the best response that I have seen so far and that it is quite simple this in the OS itself. Transcription If you are in the global scope then there is no difference. If you’re in a…
javascriptanswered Guilherme Lautert 15,097