Posts by Guilherme Lautert • 15,097 points
356 posts
- 
		3 votes4 answers489 viewsA: How does jQuery make parameters dynamic?Just adding a more complex example to reply from @bfavaretto. function f(){ var n = null; // name var t = null; // timer var c = null; // function for (var i = 0; i < arguments.length; i++){ if(n… 
- 
		1 votes1 answer278 viewsA: Password encryption problem (PHP)Whatever encryption was used for Windows in the bank. On the login screen recover the password typed and apply the same password encryption in the bank. Compare the two strings and if they are equal… 
- 
		1 votes4 answers356 viewsA: Two-dimensional ArraySituation From what I noticed this is a routine that you will call several times, ie if you should update the value of the chairs. Problems As already pointed out by the other answers, you are using… 
- 
		5 votes3 answers463 viewsA: Add Array from multiple fields# SIMULACAO $post = array( 'valor' => array( 0 => 10, 1 => 10, 3 => 10, 4 => 10, 5 => 10, 6 => 10, 7 => 10, … phpanswered Guilherme Lautert 15,097
- 
		7 votes1 answer1273 viewsQ: If the field has DEFAULT it must be NOT NULL?Situation I was adding a few more columns to a table and falls from this thought. By default here we leave all fields can have value NULL, however if he has a DEFAULT he will insert the DEFAULT in… 
- 
		2 votes1 answer604 viewsA: Sql - postgres - Arbitrary accuracy ::From the Postgres manual we can see that the Numeric has: 131072 digits before decimal point 16383 digits after decimal point This is the default value, however it is possible to set this pattern… 
- 
		2 votes1 answer604 viewsQ: Sql - postgres - Arbitrary accuracy ::How arbitrary precision works when defining the column as numeric? 
- 
		8 votes4 answers301 viewsA: How to find hashtags in a string and store them in an array?Using the @Renan comment. A by changing the answer la dada: $tweet = "this has a #hashtag a #badhash-tag and a #goodhash_tag"; preg_match_all("/(#[^ #]+)/", $tweet, $matches); var_dump( $matches );… 
- 
		1 votes3 answers76 viewsA: How to get only strings containing the word "x"As it says in the manual on strpos: Returns the numerical position of the first occurrence of Needle within haystack. If Needle is not found, strpos() will return Boolean FALSE. If you’re just… 
- 
		2 votes2 answers1125 viewsA: How to round to the nearest ten in PHP?What I use here is: function roundByValue($valor, $valorArredondamento){ if($valorArredondamento != 0){ $valor = round($valor/$valorArredondamento)*$valorArredondamento; } return $valor; } // pr =… phpanswered Guilherme Lautert 15,097
- 
		1 votes4 answers222 viewsA: Doubt in jQuery variable creationThe general rules for the construction of names for the variables (unique identifiers) are: Names may contain letters, numbers, underscores and dollar signs. Names should start with a letter Names… 
- 
		0 votes3 answers66 viewsA: How do I use my jQuery extension in the on function?From what I understand the question, you want to create a callback so that after executing the .on it performs its function clickOut. For this you must call it within the function. (function($){… jqueryanswered Guilherme Lautert 15,097
- 
		3 votes2 answers180 viewsA: Sql - Natural Ordering - VarcharThe solution I found in the OR was this Code ORDER BY regexp_replace(column_name, '\D','','g')::integer Explanation It will remove from the string anything other than number, then convert to… 
- 
		3 votes2 answers180 viewsQ: Sql - Natural Ordering - VarcharSituation I need to perform Natural string ordering. Example Processo 1 Processo 2 Processo 3 Processo 10 Processo 11 Processo 12 Standard Order. (ASC) Processo 1 Processo 10 Processo 11 Processo 12… 
- 
		0 votes1 answer137 viewsQ: Sql - Merge select - Create Row if nonexistent recordI’m willing to join two SELECT, but I am unsuccessful. Has the following tables: CREATE TABLE tb_producao ( cd_producao SERIAL, cd_setor integer, nr_quantidade numeric(12,2), ds_producao character… 
- 
		4 votes2 answers1125 viewsQ: Sql - Delete Bulk Records - Delete BulkI have a table with about 4 million records. What is the best method to delete all of them to get the best time? Indexing helps something, since it is only a reference to find data? OBS `DELETE FROM… 
- 
		1 votes2 answers1618 viewsA: Sort array by key, being a stringCode $sort = array( "A1" => "A1", "A10" => "A10", "A11" => "A11", "A12" => "A12", "A2" => "A2", "A4" => "A4", "A5" => "A5", "C12" => "C12", "C1" => "C1", "B7" => "B7",… 
- 
		0 votes2 answers224 viewsA: Regular expression to grab Youtube link in textAs I do not know if the link will always come with line break at the end defined that the size of string setting the video to be between 8 and 11 characters.… 
- 
		1 votes2 answers1434 viewsA: Get id of the marked ckeck boxfunction getIdCheckBoxByLi(_this){ var id = null; if(jQuery(_this).is(':checked')){ id = jQuery(_this).parents('li:eq(0)').find('input[type="hidden"]').attr('id'); } return… 
- 
		8 votes1 answer3372 viewsQ: Sql - Select first and last recordI have the following tables: CREATE TABLE tb_lote ( id_lote integer NOT NULL DEFAULT nextval('tb_lote_seq'::regclass), ds_lote character varying(255), CONSTRAINT pktb_lote PRIMARY KEY (id_lote) );… 
- 
		2 votes6 answers498 viewsA: What is the safe way to define a default value for a function parameter?It is common when we know how to program in one language and we are learning another, want to implement functionalities of what we already know, however this is not the right, we must learn the new… 
- 
		1 votes2 answers130 viewsQ: Is it possible to set the font size dynamically?I’m having to develop some views, and frankly define my knowledge of CSS as structural. I wonder if it is possible to create a method, without using Javascript, to set the font size to be used in… cssasked Guilherme Lautert 15,097
- 
		7 votes2 answers1633 viewsA: Loop into function calling itselfThe setInteval is a function that performs a certain function at all times in an interval of time. If you want to do it this way you should use the setTimeout that performs only once after the… 
- 
		5 votes2 answers122 viewsA: How to store form data in 2 different databases?class databaseConfig{ var $default = array( 'host' => '127.0.0.1', 'login' => 'root', 'password' => '', 'database' => 'local', ); var $server = array( 'host' => '192.168.100.101',… 
- 
		3 votes2 answers182 viewsA: preg_split is not breaking the strings in the arrayThe problem is not quite the pattern, the function preg_split, searching for the pattern to break the string into parts, that is to say it is similar to explode, however, in it you can define an… 
- 
		1 votes2 answers197 viewsA: Block splitting mysql resultsI don’t quite understand, but I’m going to assume that the people register is sequential, and you’re simply distributing people. Nor has it been defined that the break is vertical or horizontal. #… phpanswered Guilherme Lautert 15,097
- 
		4 votes3 answers3580 viewsA: How to use double and single quotes?To solve this type of problem I usually use the function sprintf, present in the PHP. 'Cause then I can write the block of text normally. PHP $button = '<button… 
- 
		0 votes2 answers960 viewsA: Preg_replace for Preg_replace_callbackFirst I recommend reading of this issue, because by the answers and the related article you see that the REGEX in PHP does not support Unicode characters, as stated by @mgibsonbr. Thus the… 
- 
		3 votes2 answers1630 viewsA: Modeling of a databaseFrom my point of view the model is practically correct. The only change I would make would be this:: Pessoa -> Endereco (1..N) Pessoa -> PessoaFisica (1..1) Pessoa -> PessoaJuridica (1..1)… 
- 
		1 votes1 answer598 viewsQ: Mask - Javascript MascaraI was transcribing some functions I have in PHP for javascript. How could I make this code more efficient ? String.prototype.substrCount = function(str){ if(str == undefined){ return 0; } var r =… 
- 
		2 votes4 answers93 viewsA: Help with programming logicthere are several ways you can accomplish this process. BANCO (Ideal) Create separate columns in the database CREATE TABLE peca{ id integer NOT NULL DEFAULT nextval('peca_id_seq'::regclass), item… phpanswered Guilherme Lautert 15,097
- 
		1 votes2 answers328 viewsA: Multiple registration of imageThe problem I noticed is the following, as you approach, your intention is to register an album with a cover image and the others being extras. However in your current role you have the upload and… 
- 
		3 votes2 answers168 viewsA: PHP - Foreach auto tuningYes would have, the passage by reference & Example : foreach($dadosUsuario as $k => &$dadoUsuario){ $nome = $dadoUsuario['name']; $lastName = $dadoUsuario['name']; $fullName = sprintf('%s… 
- 
		2 votes2 answers168 viewsQ: PHP - Foreach auto tuningDuring development, it is often the case that a request is made to the database, in which the returned data comes in array, sometimes it is necessary to perform a foreach to adjust these data or… 
- 
		1 votes2 answers238 viewsA: php regex to get 2 groups of href linkhref="([^"]+\?(page=([^&]*))[^"]+)" See working on Regex101 Basically, it captures href that contains page. And subdivides in the way you want. match[1] = toda url match[2] = page=conteudo… 
- 
		2 votes2 answers3721 viewsQ: Codeigniter - URL friendlyI’m trying to use the Codeignoter framework. but I’m not getting past it: http://localhost:8087/CodeIgniter/index.php/usuario/home for that reason: http://localhost:8087/CodeIgniter/usuario/home… 
- 
		0 votes2 answers790 viewsA: Select the country and bring the stateThe function populateCountries requires two elements select to generate the code you want. So the only adjustment you should make is to change your HTML. <select name="country"… 
- 
		0 votes2 answers135 viewsA: Array jQuery - Remove indices and concatenate htmlUsing the answer provided by @Tobymosque and searching a little more. I arrived at this solution, which fits the case more, because as I commented the HTML comes via Ajax. Or Whether it’s a string,… 
- 
		3 votes2 answers135 viewsQ: Array jQuery - Remove indices and concatenate htmlI’m performing an ajax call that retouches the Html filters to be put in a certain div. However, I would like to remove some elements of html previously. I passed the html to jQuery, thus… 
- 
		0 votes1 answer224 viewsA: Data aggregation in PHP and MVC developmentGood as you said is a Aggregation that is they have the same hierarchical level, being one independent of the other, but still related. To define the best load method you will have to check your… 
- 
		3 votes1 answer349 viewsA: PHP MVC Object OrientationYes, how I answered here. In your case, all of these are independent, there is no relationship between them. Teacher is a feature, as well as student, and admin. Class is a context. The Teacher can… 
- 
		3 votes1 answer92 viewsA: How to match four or more arrays?To combine this data you can create in two-dimensional array: $dados = array(); foreach($nome as $k => $value){ $dados[$k]['nome'] = $value; $dados[$k]['email'] = $email[$k]; $dados[$k]['idade']… 
- 
		2 votes2 answers108 viewsA: Regex - picking certain values - PHPI believe the REGEX you need is this: ([^\.]+)\.{2}([^_]*)_{0,2} Whether working on Regex101 Explanation ([^\.]+) = Grupo 1, vai pegar qualquer coisa que não seja '.', no minimo 1 vez \.{2} =… 
- 
		1 votes1 answer711 viewsA: Read TXT file with PHP and write to mysql$file = 'file.txt'; $resource = fopen($file, 'r'); $lines = ''; while(!feof($resource)){ $lines[] = fgets($resource, 4096); } $fullVar = true; $fullVar = $fullVar ? ':' : ''; $er =… 
- 
		0 votes3 answers6543 viewsA: How to mask the URL after hiding a GET with history.pushState?I joined the responses from the @Sergio, @Baccon comments. Be it in the jsFiddle HTML <div id="conteudo"></div> <form name="paginacao" id="paginacao" method="post"… 
- 
		18 votes3 answers437 viewsQ: Database should follow the OO standard?Object Orientation According to the Rules of Pure O, we have: "The Object must manipulate methods and attributes belonging only to it" That is, what does not strictly belong to class should be an… 
- 
		2 votes4 answers1466 viewsA: How best to pass values to attributesObject-Oriented Programming Object "Object is anything existing in the real world, in concrete or abstract format, that is, that exists physically or just conceptually." Object incorporates data… 
- 
		2 votes4 answers824 viewsA: Regular Expression to get what’s outside of bracketsSee working on Regex. Any clarification ask. Pattern: /^([^\]]+) \[([^\]]*)\]/gm Input: Itau [2.265,41] Bradesco [1.375,21] Santander Bradesco [784,12] Caixa 2 [] Match: MATCH 1 1. [0-4] `Itau` 2.… regexanswered Guilherme Lautert 15,097
- 
		9 votes3 answers15565 viewsA: Which regular expression can I use to remove double spaces in Javascript or PHP?Some types of "writeSpace" " " espaço simples - represente o " " espaço \n - representa a quebra de linha \r - representa o retorno de carro \t - representa um tab \v - representa um tab vertical… 
- 
		5 votes2 answers189 viewsQ: Regex - Operator "." - Meta character captureSituation I’m conducting a survey with regex in a specific word inválido, but I decided to use inv.lido. Which I knew I had in the test string but didn’t return. Testing vr = var_dump pr = print_r…