Posts by BrunoRB • 5,526 points
93 posts
-
2
votes2
answers463
viewsA: Display empty directories only with the ls command
Use: find . -mindepth 1 -maxdepth 1 -not -empty -type d Where . is the path to the directory you want to list, in which case he is looking in the current directory.…
-
3
votes1
answer108
viewsA: Algorithm for sorting the elements of a data set
I’m not going to give you a straight answer because, as commented by Maniero, the OS community discourages doing other people’s homework. However giving you a direction if you are lost: what you…
-
12
votes3
answers2963
viewsA: How to measure the complexity of an algorithm?
Measuring the complexity of an algorithm is traditionally done in computer science using asymptotic analysis which uses what is called notation Big O (o(n) of which its statement speaks). An…
-
33
votes6
answers4038
viewsA: What is lexical analysis?
Definition Lexical analysis is the process performed on a text, say a computer program or a markup language such as HTML, which divides this into lexemes and converts them to a sequence of tokens,…
-
1
votes5
answers6291
viewsA: Encrypt string based on a php keyword
Yes, look for the functions openssl_encrypt and openssl_decrypt.…
-
6
votes3
answers2099
viewsA: Is it safe and feasible to minify PHP files?
What you should minify is the content sent to the user’s browser, HTML, Javascript and CSS. Minifying your PHP code does not bring advantages, just complicates your development process. If your HTML…
-
12
votes3
answers53541
viewsA: How does the DAO Standard work?
The DAO standard has the main purpose of abstracting the access to the data source of your application (usually a database such as postgresql, mysql, mongodb, etc.) from the parts that use or…
-
5
votes1
answer1284
viewsQ: php vs nodejs performance on websockets server
What I take for granted at the moment is that nodejs is more suitable to work with a constant pool of socket connections (websockets in this case) because being single-threaded each new connection…
-
4
votes4
answers5293
viewsA: How to check if the user is online?
The question has already been marked as answered, but as a reference for those who stop here in the future: use websockets, they have been around for some time and are the most suitable solution for…
-
1
votes2
answers193
viewsA: Function for handling all date type parameters in a Multilevel object with Javascript
A recursive function: var jsonObj = { idPedido:1, dataCriado: "/Date(1454637600000-0200)/", cliente: "Nome do Cliente", pagamento:[ { idPgto:1, valor: 100.00, tipoPgto:"dinheiro",…
javascriptanswered BrunoRB 5,526 -
3
votes1
answer49
viewsA: Can overuse of constants affect system performance?
Yes you can, but "overuse" would be defining thousands constants in each page load. Are you setting 20, 50, maybe even 100? So it’s probably irrelevant and trying to change that would be…
-
0
votes1
answer92
viewsA: Is it possible to use Setoutputfilter DEFLATE without caching copy?
Yes it is possible and it is exactly the way you did. How did you test it? using exactly your rules in mine. htaccess the copy lock in the cache works perfectly. Just look at the result using the…
-
11
votes1
answer1667
viewsA: What is the goal of implementing a magic __invoke method in a class?
__invoke makes sense when you need one callable that can maintain an internal state. Say you want to sort an array: $arr = [ ['key' => 3, 'value' => 10, 'weight' => 100], ['key' => 5,…
-
2
votes1
answer474
viewsA: Is it correct to name html tag attributes arbitrarily?
Yes and no: you can not get added imaginary elements as for example meunovoatributo="xxxx" since HTML considers valid only a number of predefined attributes in the specification. However data- has…
-
0
votes1
answer288
viewsA: Run an UPDATE on Mysql only when the number of Rows is 1
CASE WHEN it seems to me the ideal here. If the table you want to use be different of the table whose number of Rows you need to check can do something similar to this: UPDATE tabela2 SET campo=…
-
5
votes3
answers395
viewsA: How to specify directory where Bower will place dependencies?
Use --config.cwd=[path], example: bower install jquery --config.cwd=/home/brunorb/test # /home/brunorb/test/bower_components/jquery/ Note that it still creates the folder bower_components within the…
-
14
votes4
answers1308
viewsA: What is the purpose of an empty parenthesis "()" in a regular expression?
Depending on the case just confuse who is reading the regex. Parentheses indicate group capture, so in the expression (DE)()([0-9]{1,12}) DE will be captured in the first group, in the second we…
-
9
votes5
answers631
viewsA: str_split does not work well in string containing UTF-8?
As already mentioned, most of the standard PHP functions do not support multibyte strings and for these cases the ideal is to use the multibyte string functions. Being more specific in the case of…
-
3
votes1
answer319
viewsA: Why does the PSR2 standard require us to use 4 (four) spaces instead of tab?
Had a vote and decided they would be spaces. Quoting the specification: Using only Spaces, and not Mixing Spaces with tabs, helps to avoid problems with diffs, patches, history, and Annotations. The…
-
-1
votes3
answers82
viewsA: Should I allocate the member of the date structure as well?
Yes, how data is a pointer you must allocate memory to it separately after you have allocated Lnode. When you allocate memory to Lnode will be for the structure, that is, memory for the whole id and…
-
11
votes2
answers625
viewsA: Is it really necessary to use mutator and access (Setter and getter) methods in PHP? What about performance?
Getters and Setters were not created in Java, but were popularized by it, so their mandatory use is part of the hyper-abstraction culture of language where you can never write something that just…
-
0
votes1
answer170
viewsA: Add information to a. json file
Yes, it is possible, however first note that your JSON structure is invalid, this doesn’t make sense here 'id': 'rt6hj7'{ then you should start using a valid JSON, ex: { "rt6hj7": { "nome": "Miguel"…
-
4
votes2
answers610
viewsA: Is it bad to use the standard PHP session engine?
It depends. The use of Sessions PHP default does not present problems in general, however it can be bad depending on how it is used. The save Handler pattern uses files, so in each request received,…
-
5
votes3
answers10597
viewsA: Add element at the beginning of a key object/value
The exemploLista that you are using and is created with the notation {...} is a object and not a array. In javascript objects are basically hash maps ({key: value}) and according to the…
-
0
votes3
answers4599
viewsA: Javascript - save/update content
Only with HTML/javascript no. HTML is a static set of tags and text, the only way you can "save" a change to a file of this type is to edit it, either with a text editor or with a programming…
-
10
votes3
answers600
viewsA: What does this() do alone in the builder?
It invokes the constructor that does not receive parameters, for example in the expression Livro l = new Livro(autor); what will occur is the following: new Livro(autor) will invoke the book builder…
-
3
votes2
answers1708
viewsA: Is it correct to concatenate PHP in Javascript?
At first it is good to clarify that "Concatenate PHP in JS" is perhaps not the best description of what happens there, I believe that the most correct term would be something like "Dynamically…
-
1
votes1
answer283
viewsA: How to block CSS from changing beyond Footer and Header
The easiest way is to take the user-defined CSS and encapsulate it with the header|footer selector (if these are exactly the ones you’re using) through your own code. So if you have a structure…
-
1
votes1
answer95
viewsA: Font approval using SVN
For you to do exactly what you want, get the commit on the server and keep it out of the repository until the moment you give an approval, I believe it would be reasonably complicated, you need to…
-
1
votes1
answer154
viewsA: Find element that the ID is generated randomly
As the implementation of Selenium for python allows you to use CSS and XPATH selectors this is trivial, examples: # XPATH table = driver.find_element_by_xpath("//table[@data-recordid='879']") # CSS…
-
5
votes4
answers426
viewsA: Contest question: logic error and semantic error?
It could be a semantic error if somewhere in the question is specified that the notes can be rational numbers, so it would be a mistake to use "Integer". It could also be considered a logic error to…
-
7
votes2
answers8899
viewsA: Cannot read Property '0' of Undefined, prototype incompatibility
The bug occurs because you are using lib prototype js., which extends the native javascript array object including numerous new methods in it, as you iterate over the "items" array with the for…
-
3
votes1
answer207
viewsA: How to restrict customers who receive messages with socket.io
The ideal in this scenario is to use the concept of Rooms that the socket.io exposes. Basically you group certain sockets, in this case those of your friends, in a "room", so you can send…
-
1
votes1
answer94
viewsA: Remote file cache with interval updates with PHP
What you need is to use a caching system like the memcached. In your code that picks up the JSON you make a conditional check that sees if this JSON is already stored in the cache, if you are just…
-
3
votes3
answers1808
views -
7
votes2
answers995
viewsA: PHP 7 has argument typing and return, but is it optional. Is that good or bad?
Strictly speaking the real reason for "why is it so?" you would have to ask to the staff who proposed and voted acceptance of these features, however it is not very difficult to deduce the reasons…
-
12
votes5
answers7178
viewsA: What is the advantage of using recursive functions?
Recursive functions are an advantage for cases where the problem is naturally defined as a function of itself, and where the recursive solution is the simplest. At first this may seem strange since…
-
8
votes1
answer1943
viewsA: What is Database Connection Pool?
When you need to perform any operation on a database you first need to establish a connection to it, such a connection is usually done using the protocol TCP/IP and it will always cost to be opened…
-
5
votes1
answer1031
viewsA: Table structure for genealogical tree
Tree structures are recursive by nature and a possible model would be a table in which each person has a field id and a field child_id which points to the child’s id, this way you can set the tree…
nomenclatureanswered BrunoRB 5,526 -
4
votes3
answers13730
viewsA: What is the difference between simply-chained and double-chained list?
The difference is that in a simply chained list each node in the list has a pointer to the next node: Already in a doubly chained list each node in the list has a pointer to both the next node and…
-
1
votes1
answer1222
viewsA: Field Primary key from int to bigint
The problem there is that you are trying to change the type of a Primary key field that has Foreign Keys referencing it, this is not allowed as a Foreign key field always has to have the same type…
-
1
votes1
answer2412
viewsA: Select recursive in mysql data hierarchy
The following precedent receives the ID of the initial node, the "side" you want to check and returns the id of the last found descendant, or the initial node itself if it has no offspring on the…
-
4
votes3
answers1072
viewsA: Regex pick certain digit size and or symbol
More complicated than it looks ! To deal with all possible cases I believe that this is a correct regex: (?:^|(?<=[^\d]))\d{9}(?:!|(?=[^\d])|$) It "says" more or less the following: "give me all…