Posts by Guilherme Lautert • 15,097 points
356 posts
-
1
votes1
answer77
viewsQ: How does the Deploy process in Golang work?
Situation In my company we are starting a technology exchange process. And one of the suggested was Golang. And one of the biggest obstacles is the deployment process. Experiments In PHP, even being…
-
4
votes1
answer252
viewsQ: Is there a name for "3-state Boolean"?
But as such a "Boolean of 3 states"? It is usually used in comparing dates, where possible results are -1, 0, 1. I was in a similar situation and I was left with this doubt when I wanted to ask my…
-
4
votes3
answers957
viewsA: How to set default value in a form through javascript?
// JS Puro document.getElementById('codigo').value = "Teste" // jQuery $('#codigo').val('Teste 2'); <script…
javascriptanswered Guilherme Lautert 15,097 -
1
votes2
answers152
viewsA: Regex to match in citation title
The logic I thought was this: : Authors Title Descriptions Thus it is possible to define the following rules : Authors : surname + comma + space + name + period = BERNERS-LEE, T.; Several authors…
-
2
votes1
answer1367
viewsA: How to create a numeric system?
Analyzing again I found that my idea is in fact about base 7 itself, only with a conversion at the end. Analogy If I need to create a basis with 0125689 would be the same as creating a abcdefg. With…
conversionanswered Guilherme Lautert 15,097 -
3
votes2
answers1541
viewsA: Regex filter only values in real
The problem is you’re leaving everything as "optional" (*). The REGEX that can help you is : ~R\$:[\t ]*(\d{1,3}\.?)+(,\d{2})?~ See in REGEX101…
-
0
votes4
answers4237
viewsA: Validation for Phone type field
I use the jQuery Mask plugin, to manage my masks. Code I just adapted the ending to validate your need. $(document).ready(function(){ $('body').on('focus', '.phone', function(){ var maskBehavior =…
-
2
votes1
answer1367
viewsQ: How to create a numeric system?
Situation I recently received a challenge in college to do : From the decimal system 0123456789, using only the numbers that mirrored can still be read find the thousandth number of this system.…
conversionasked Guilherme Lautert 15,097 -
4
votes3
answers304
viewsA: Where is the error in replace js?
The @dvd has already explained the reason. replace only accepts 2 parameters: replace(string_buscada, nova_string); My contribution is in the method of doing this, which would be using a callback in…
-
8
votes4
answers55577
viewsA: How to validate client-side CPF with script?
I adapted the response script from @Albertbitencourt. Removing the party you consider 10 and 11 as 0, because apparently this validation does not exist. function cpf(cpf){ cpf = cpf.replace(/\D/g,…
-
0
votes2
answers1441
viewsA: Find regular expression record in mssql
You can use the following regex for this : #([^#]*)#=([^#]*)(?:;|$) Explanation #([^#]*)#= - It will capture the "attribute". ([^#]*) - Takes the value (?:;|$) - No capture group that says the value…
-
1
votes1
answer247
viewsA: REGEX to get information inside a string
From what I understand, your question qualifies as Lexer or interpreter. However you have your interval well defined, although you don’t know exactly how you will treat it afterwards. You can use…
-
24
votes2
answers67807
viewsQ: What are the acronyms DDL, DML, DQL, DTL and DCL?
I was setting up a permissions structure in the bank (GRANT, REVOKE), when I found this article and found it interesting to share, even to have here at Sopt. Original issue What is DCL? Source…
databaseasked Guilherme Lautert 15,097 -
48
votes2
answers67807
viewsA: What are the acronyms DDL, DML, DQL, DTL and DCL?
Think like this, the SQL language is only one, but it is divided into types according to the functionality of the commands. The SQL language types are: DDL - Data Definition Language - Data…
databaseanswered Guilherme Lautert 15,097 -
0
votes1
answer461
viewsA: Postgres - Permissions within the function
This can be done by adding the parameter SECURITY DEFINER in function, as explains in the documentation. The function is executed with the privileges of the user who created it. So you can grant the…
postgresqlanswered Guilherme Lautert 15,097 -
0
votes1
answer461
viewsQ: Postgres - Permissions within the function
I am setting up a system in which the user will have a very limited access, just view and perform certain specific functions. Scenario (with root user) Has three tables : Person Device Access And…
postgresqlasked Guilherme Lautert 15,097 -
4
votes4
answers24927
viewsA: Regex - Picking text up to a given string
If you are using a library with more resources like PCRE. Could use : /(?(?=\s+)|(?(?=\w\))(?<a>\w\).*)|(?<q>.*?\n)))/g See working on REGEX101 Here I am using "conditional" and "nominal…
regexanswered Guilherme Lautert 15,097 -
2
votes1
answer34
viewsA: Regular expression to remove images containing a height range in inline style
As its interval is 29 to 45 or is it relatively regular, the logic would be as follows : Separate decimals and units Verify which is the Rang of each of them Decimal : [2-4], unity : [0-9] => \d…
-
6
votes1
answer97
viewsQ: Does removing a DOM element also remove your listening?
I already know the appeal of Dirt collector. My doubt is in relation to this recourse to the addEventListener. Example test.addEventListener('mouseover', function(){ test.className = 'active'; });…
-
3
votes2
answers256
viewsA: Function javascript duplicating trigger by init method
The problem is that the called action of the function "started" you this adding in the event list of the ". Edit-collaborator" element a new call. Think of a array with the list of all calls to this…
-
4
votes2
answers2522
viewsA: Regular expression for Telephones only with numbers and DDD C#
No real need to validate DDD, only digits remain : \d{10,11} var list = [ '5112345678', '61123456789', '1112345678', '21123456789', ]; for(var i in list){ console.log(list[i],…
-
17
votes1
answer413
viewsA: How does "positive" (?=X) work combined with "positive" lookbehind (?<=X)?
You must have heard that phrase that says : Just because you’ve reached your goal doesn’t mean you’re right Well, what happened with your REGEX is the following, I will explain with another to be…
regexanswered Guilherme Lautert 15,097 -
18
votes1
answer1194
viewsA: Regular expression to recognize language: words that do not contain "bbab"
Good let’s see that the Language L accepts following the premise: {a,b,c,d} - so we have that the only characters present in the language are a,b,c d, * - all possible words that can be formed by…
-
2
votes1
answer684
viewsQ: Manage video with PHP
I’m setting up a file management system, but I’m having problems with displaying the videos. It has an interpreter and in a certain part I have a "ignorer". $mime = mime_content_type($path);…
-
0
votes1
answer71
viewsA: Rewriterule conflict in htaccess
To solve your problem, you should know how to analyze the level of specification of your rules. The most specific rules should be at the top. But as well as level of specification? The level of…
-
0
votes4
answers837
viewsA: Problems with conditional structures
Instead of trying to define "approval" by the letters after the "concept" process you could work again with the media. So still getting independent of each other. nota1=float(input("Digite nota 1:…
-
1
votes2
answers422
viewsA: Capture words using Regular Expressions
Assuming that their links are all in one string separated by \n. You can use REGEX : ~MeusRelatoriosPDF\d+\-(\w+)(?:\-(\w+))?(?:\-(\w+))?~ $links = "MeusRelatoriosPDF001-Capa-Disclaimer-22012017…
-
1
votes4
answers7010
viewsA: jQuery delete the last character typed in an input
I like REGEX so I will provide an answer with the same though the one from @jbueno already perfectly resolve the issue. $('#excluir').on('click', function (){ var input = $('#txt')[0]; input.value =…
-
0
votes1
answer111
viewsA: REGEX - How to capture blocks of CASE WHEN ... END
The main problem is the "end" as it would be the end delimiter. And as you have "end" in the middle of the string it is not possible to do simply (?i)(CASE\s+WHEN.*?END) for the capture becomes…
-
6
votes1
answer1399
viewsQ: What is the difference between Alt, poweroff and reboot?
I have heard several times that if I want to shut down/restart the computer from the terminal just run one of these options : Halt poweroff reboot poweroff and reboot are very intuitive "shut down"…
linuxasked Guilherme Lautert 15,097 -
2
votes2
answers1013
viewsA: Regular expression to select whole word and case sensitive in sharp word
As you are working with word search in text the word search delimiters are not the ^ (beginning), $ end, as these refer to string entire. ^ - beginning of string $ - end of string To solve this case…
-
1
votes7
answers5040
viewsA: Regular expression for accepting numbers and letters, regardless of sequence
You can even set up a REGEX for this, but it would be huge, precisely because not be regular, since the numbers can be anywhere in the password. The ideal in your case is to build an algorithm like…
-
2
votes4
answers1037
viewsA: Capture form data and transform to UPPERCASE
You can do this at once in the form submission, so don’t overload js with unnecessary events. $('form').submit(function(){ var data = {}; jQuery(this).find('input[type!=submit],…
-
0
votes1
answer1047
viewsA: Resize image according to device size
Development via JS function resizeImg(){ // DIMENSÕES PADRÕES var defaultIMG = { w : 360, h : 640 } // PEGA O TAMANHO DA TELA (NESSE CASO content_window) var w =…
-
0
votes1
answer1047
viewsQ: Resize image according to device size
I have an image that has by dimensions 360 x 640 pixels and should be used as background of a div. At first div will occupy the entire screen of the device. Situation Due to my application being…
-
1
votes1
answer189
viewsA: User-friendly URL with htaccess pointing
You can do this with capture denied [^ ]. RewriteRule ^\/?[^\/]*(\/(.*))?$ /pasta_do_site/$2 [L,QSA] Be working in REGEX101. Explanation \/?[^\/]* - capture of the "anything" that should end in the…
-
2
votes8
answers955
viewsA: split/regex only on the first vertical bar "|"
As it comes to the first occurrence, you could do so : text = "João|||23anos|"; console.log(text.replace('|', '{spl}')); // SUBSTITUI A PRIMEIRA OCORRENCIA console.log(text.replace('|',…
-
7
votes2
answers758
viewsQ: What does the return of the INSERT 0 1 bank mean?
When I perform commands in the bank I have returns to and execution of the same. Doubt What does the 0 in INSERT 0 1? Example CREATE TABLE test( id SERIAL, name VARCHAR(50), PRIMARY KEY (id) );…
-
6
votes4
answers832
viewsA: Can I use onclick twice ?
You can separate the commands on onclick through the ; <input type="button" value="click me" onclick="alert('alerta1'); alert('alerta2');" />…
-
2
votes2
answers713
viewsQ: Why is the screen size in the browser different from the real one?
I’m terrible when it comes to HTML design + CSS, but as a web programmer, I often find myself having to do it. Often I have to do such things media-query to adjust the layout. Question If I have a…
-
4
votes3
answers2728
viewsA: How to select this piece of text in Regex
If I understand correctly you want to filter a part of the content and want to replace it. So even if there is something else you want it will always be something like : 1.1.1.1. Testing. 1.1.…
regexanswered Guilherme Lautert 15,097 -
2
votes1
answer278
viewsA: Redirect domain to a particular server folder via htaccess
To perform this task it is necessary to use the Rewritecond <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} .*dominio1.* [NC] RewriteRule ^(.*)$ dominio1.php [L] RewriteCond…
-
4
votes2
answers318
viewsQ: PHP mkdir vs chmod
I was creating folders dynamically by PHP, when I came across the following situation. Occurred Create a folder tmp with permission 777 in /www mkdir('/www/tmp', intval('0777',8), true); Turns out…
-
2
votes1
answer268
viewsA: Domain forwarding in file . htaccess
Let’s go in pieces : <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.*)$ # REMOVE O www DA FRENTE DO DOMINIO RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,L]…
htaccessanswered Guilherme Lautert 15,097 -
0
votes3
answers741
viewsA: Compare data from two tables
Already set up address system so, the relationship is very simple, just connect via table id, the DBMS itself will create new lines for each different address. SELECT cidade, bairro, logradouro FROM…
-
4
votes3
answers199
viewsA: How to make a look-Behind using quantifiers such as the " d+"?
The Response of @Wtrmute this in accordance with your need, but let us focus on your doubt. How to make a look-Behind using quantifiers? Answer You don’t do, the look-Behind would have the logic…
regexanswered Guilherme Lautert 15,097 -
0
votes4
answers5283
viewsA: Separate an array into groups?
function separar(arr, len){ var r = [], i = 0, last; r[i] = []; do{ do{ r[i].push(last = arr.shift() || r[0][0]); }while(r[i].length < len); if(arr.length >0){ r[i++] = []; r[i].push(last); }…
-
0
votes1
answer159
viewsA: Press virtual keyboard buttons according to password
I rode in JS var teclas = [{"a":1,"b":5},{"a":6,"b":7},{"a":4,"b":9},{"a":8,"b":2},{"a":3,"b":0}]; var password = '011232'; var check = 0; function checkPassword(e){ var index =…
-
1
votes1
answer388
viewsA: What does the ER look like to mask an Anumeric code?
You can use the Lib jQuery-Mask // 0DF7M3-R34X21 $('#test').mask('AAAAAA-AAAAAA'); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script…
-
1
votes2
answers1578
viewsA: How to go back to the previous page when clicking Esc?
For your case it may be a bit over the top, but you can use the library I set up Keymap. document.onKeyMap('esc', function(){ // history.back(); <-- COGIGO REAL alert('ESC'); }); <script…
javascriptanswered Guilherme Lautert 15,097