Posts by BrunoRB • 5,526 points
93 posts
-
0
votes1
answer4034
viewsA: Nodejs - Typeerror: Cannot read Property 'get' of Undefined
You need to define app (which is an instance of express), example: let express = require('express'); let app = express(); app.get('/noticias', (req, res)=>{ res.render('noticias/noticias') })…
-
7
votes4
answers2051
viewsA: Dropping indexes or Foreign Keys in a table can slow the query?
In general maybe, depends maybe, depends maybe, depends A little less general INDEXES improve searches with specific values in indexed columns (including joins) but incur overhead in INSERT|UPDATE,…
-
8
votes3
answers1210
viewsA: How to organize a project in Ode
What I use is more or less this here: - src/ - main.js - modules/ - [controllers] - [models] - database.js - [script variados: util.js, http-server.js, socket-server.js, etc] - views/ - [templates:…
-
1
votes1
answer134
viewsA: Pass a method on all routes of all http methods except two
Middleware. Just declare one before your routes, and set the logic on it to allow or refuse the request: var app = express() app.use(function (req, res, next) { // endpoints ignorados if ((req.url…
-
0
votes4
answers938
views -
2
votes1
answer59
viewsA: Is it possible to use Mariadb for Clusterization?
There are some options, but the one I know and have used personally (and would recommend) is the Mariadb Galera Cluster, a cluster multi-master for mariadb. A multi-master cluster is where any node…
-
-1
votes2
answers120
viewsA: Access system by remote access
You could create the application by having a communication API, all logic would be in the central server and in the client you would have only a graphical interface that sends commands over the…
desktop-applicationanswered BrunoRB 5,526 -
2
votes1
answer65
viewsA: Compile multiple JS keeping the original names
var fs = require('fs'); // retorna todos os arquivos dentro do diretório dir let getFiles = function (dir) { return fs.readdirSync(dir).reduce((prev, file) => { var fullPath = `${dir}/${file}`;…
-
5
votes2
answers2317
viewsA: What is Xpath and what is it for?
Briefly Xpath is a language of searching for us in documents XML (but also used in HTML), you execute an Xpath expression on a certain XML/HTML/ document any supported ML and the result will be 0 or…
-
4
votes4
answers320
viewsA: Flatten lists. Is a more concise solution possible?
reduce! Python2: listas = [[1, 2], [3, 4, 5], [], [6, 7]] reduce(lambda prev, next: prev + next, listas) [1, 2, 3, 4, 5, 6, 7] This is for list lists. But what about list lists for list…
-
2
votes2
answers2434
viewsA: In terms of performance, "Character Varying" or "text" in Postgresql?
Postgresql documentation on char types (char, varchar and text): There is no performance Difference Among These three types, apart from increased Storage space when using the Blank-Padded type, and…
-
2
votes2
answers713
viewsA: Dynamic grouping of JSON data
Here is a simple algorithm that groups your data based on an arbitrary amount of attributes: var lUsuarios=[{"NOME":"ANTONIO CARLOS…
-
36
votes2
answers13039
viewsA: What is CI/CD? Benefits and Risks
Although the question is clear about not having much interest in the formal concepts of IC and CD by these being easily found on google I found it good to give a basic introduction in both to make…
-
0
votes7
answers1017
viewsA: Is there any way to know if an array is associative or sequential?
A very concise solution using the solutions range and array_keys: // true caso $arrayVar seja uma lista sequencial (indexada de 0 até N, sem gaps) array_keys($arrayVar) === range(0, count($arrayVar)…
-
1
votes1
answer420
viewsA: Remove subdirectories with htaccess
Assuming that the mod_rewrite is enabled you can do the following in your . htaccess: RewriteEngine on RewriteBase / RewriteRule ^lojanova/(.+)$ $1 [R=301,L] RewriteRule ^lojanova(/)?$ / [R=301,L]…
-
3
votes1
answer194
viewsA: Validate increasing and decreasing numbers with regex
You could do the following: ^0*1*2*3*4*5*6*7*8*9*$ to detect crescents, ^9*8*7*6*5*4*3*2*1*0*$for decreasing and ^0*|1*|2*|3*|4*|5*|6*|7*|8*|9*$ for repeated, example: import…
-
1
votes2
answers145
viewsA: create_function can be a risk to my code?
You can use the function create_function, however you need to avoid problematic use cases of it. First, how this function uses eval internally, is very important that does not pass any data entered…
-
4
votes2
answers1092
viewsA: Comparison between 2 equal numbers returning 'false'?
The problem is because the value of $fullprice or of $cart->getData('subtotal') is actually a real number extremely close to 319.2, something like 319.1999999999999. You can reproduce this case…
-
6
votes3
answers2738
viewsA: How does the browser handle infinite loop in Javascript?
As 1 and 2 have already been well answered in the comments of the question and in Sergio’s response I’ll just give you an additional on 3: It’s interesting to understand how detecting an infinite…
-
10
votes1
answer2888
viewsA: What is the purpose of virtualenv and why not install globally?
Using Virtualenv you isolate the dependencies of one project from those of others, some examples where this saves lives: You work on multiple projects simultaneously, and some use X version of a…
-
4
votes4
answers135
viewsA: How does object copying work?
Your second assumption is wrong, see: var a = {a: 1, b: 2}; function b(objeto) { objeto.a = 3; } b(a); document.write(JSON.stringify(a)); a.a becomes real 3 when you do objeto.a = 3;, then the…
-
1
votes2
answers380
viewsA: Algorithmic complexity of map
Initially a map is O(n) because internally it iterates over the list, a linear operation, and also creates a new list of the same size to receive the transformations, also a linear operation, so we…
-
0
votes2
answers121
viewsA: Turn cycle into higher order function
You could use conditional expressions (kind of an exotic ternary) and return None case [0] is different from y and then apply a filter to remove the Nones: def higherOrderCycle(x, y): return sorted(…
-
4
votes2
answers138
viewsA: Remote reading on Android: Json or XML?
Briefly JSON is quite concise and easy to interpret by the machine. Already XML is more expressive, you can express complex dialects, however it is quite verbose in relation to JSON, so the…
-
1
votes2
answers498
viewsA: Service versus Broadcastreceiver
A service is a component that performs long-term actions in the background, it does not present a user interface. As an example you could create a service that accesses a certain external API in…
-
4
votes3
answers319
viewsA: How to disable console.log for a particular js file?
At the beginning of your file do: var __log = console.log; console.log = function() {}; And at the end of it restore console.log with: console.log = __log;…
javascriptanswered BrunoRB 5,526 -
1
votes2
answers529
viewsA: Atom text-editor - When clicking the function go to code
preferredLineLength has to do with column size in the row and not going to the source code with Ctrl+click. You need to install a plugin that gives you this functionality. For PHP you have this one…
-
3
votes1
answer369
viewsA: When my class returns a modified new instance of the class itself instead of modifying it itself, is it a project pattern?
The pattern is immutability, transformations into objects and structures never change the original reference, instead they are applied to a new object/structure that is returned. This comes from…
-
8
votes3
answers1686
viewsA: Are there safer languages than others?
In contrast to Maniero’s response I say that languages are inherently safe or insecure in their context of use (say OS Programming or web Programming) and they are one of the determining factors in…
-
5
votes3
answers434
viewsA: Is it correct to omit the html start tag in HTML5?
Interestingly it is valid yes, as you can see on own specification of w3c the opening of the tag can be omitted provided that the first thing within the scope of the html tag is not a comment, so…
-
7
votes2
answers5233
viewsA: How can I test method with void return using Junit?
You test the side-effects caused by the method. For example if your void method changes some attribute of the class the test should check if before the call the value of the attribute was X and…
-
23
votes3
answers9745
viewsA: What are Javascript Promises (promises)?
Promises (or Promises) are an abstraction used to represent action flows in asynchronous code, and in Javascript Promise is an object that represents the result of an asynchronous operation, this…
-
4
votes2
answers792
views -
2
votes3
answers237
viewsA: jQuery influences the application’s "performance"?
Yes influence, however in most cases the difference is irrelevant in the final result because the Javascript engines in the current browsers are extremely efficient and jQuery is already well…
-
6
votes2
answers1146
viewsA: How to make a regular expression to remove only the hyphen without removing the hyphen arrow
You can use Negative Lookahead "(?!)", deny a pattern that comes in front of another pattern. Example in php: preg_replace('/-(?!>)/', '', '00000-001->22222-222'); Or in javascript: var result…
-
0
votes2
answers600
views -
1
votes1
answer261
viewsA: Mysql to Mariadb Migration
Assuming you use mysql-mariadb equivalent versions you could yes migrate without any problem because mariadb is Backwards compatible with mysql, just make sure you have backups before.…
-
1
votes2
answers300
viewsA: Import . sql from Postgresql in Neo4j
There’s no easy way. You will have to import this SQL into postgresql, create its equivalent structure in NEO4J and then write a mapping code of the data that will extract them from postgres and…
-
2
votes2
answers1837
viewsA: Desktop Friendly Web Application
Some options: Electron nw js. Chromium Embedded framework, also known as CEF (more "low level" than the previous) there are other alternatives, just give a search They are frameworks that allow you…
web-applicationanswered BrunoRB 5,526 -
2
votes2
answers870
viewsA: Problems making an ajax request
Every time you click on your button call the function sub (onclick="sub('achadoPerdido','Incluir')"), this in turn creates a Manager for the Submit event in the element #form…
-
3
votes2
answers86
viewsA: Is it safe to use Javascript’s String.Concat method in current browsers?
It is safe, the function is old and you can use it without fear (it comes from the standard 1.2 of js, this is Netscape 1997!) however it is not recommended because the performance is unfortunate…
-
0
votes2
answers156
viewsA: What to use instead of "-use-mirrors" in the PIP?
You can use --index-url or --extra-index-url to manually determine the package mirrors, see the changelog: BACKWARD INCOMPATIBLE Pip no longer Supports the --use-mirrors, -M, and --mirrors flags.…
-
1
votes4
answers1429
viewsA: How to search for results in Mysql where a given field only has special characters?
^([[:punct:]]|[[:cntrl:]]|[[:blank:]])+$ Will match all fields that only contain scores or control characters or spaces/line breaks, the following fiddle contain an example of use.…
-
0
votes1
answer757
viewsA: Take content from a div and save to a regular expression array (PHP)
Ana trying to take the content of HTML elements with regular expressions is a bad idea and at best it will only work partially because HTML is not a regular language (which is the type that regular…
-
19
votes4
answers4351
viewsA: How and why use MVC in PHP?
introducing MVC is the acronym for Model View Controller, an architecture standard used as a general structuring form of code that generates a user interface (html/css/js in the case of php). The…
-
4
votes5
answers12645
viewsA: How to create a vector without determining its size in Java?
Not exactly, the size of arrays must be set at some point and you cannot change it after that. An alternative would be to just declare your array Teste[] t; and set the size at some later point with…
-
8
votes1
answer769
viewsA: How to decrypt encrypted email in SHA-256?
Not possible. SHA-256 is a function hash and as such it is "one way", after conversion there is no turn, there is no "decryption" process. If for some reason you want to encrypt the emails in the…
-
2
votes1
answer51
viewsA: Is there a performative difference between on chained with on with multiple events?
There is no difference in performance, underneath the scenes both versions saw a simple elem.addEventListener( type, eventHandler, false ); for each event you have passed (where type is the name of…
-
2
votes1
answer64
viewsA: Difference in Socket.io declaration
socket.emit will issue the event to this specific socket, in case any client is connected and represents the socket. In chat.emit the event is issued to all clients that are connected in the…
-
2
votes2
answers375
viewsA: Should I compress files to save to the database?
It depends on how often you will want to access these files. If they’re gonna be out there mowing most of the time, and assuming you don’t have or can’t get more disk space, maybe it’s worth it. Now…