Posts by Costamilam • 9,556 points
509 posts
-
3
votes1
answer101
viewsQ: REST in the microframework Inphinit
To experimental functionality REST Inphinit microframework requires a class with 7 functions index create store show edit update destroy In a REST API basically two are required entry points for the…
-
3
votes2
answers274
viewsA: How to use querySelectorAll without having to specify array elements afterwards?
The simplest way is to add event listeners within a loop: for (const element of document.querySelectorAll(".obj-item")) { elememt.addEventListener("click",function(event){ ... }) } But you can add…
javascriptanswered Costamilam 9,556 -
15
votes1
answer314
viewsQ: Is the HTTP protocol in version 2 still stateless (stateless)?
HTTP is a stateless protocol (stateless), i.e., requests and responses are independent, so the server does not need to store any data from any previous action. But with its new version (HTTP 2), a…
-
2
votes2
answers47
viewsA: How to filter an object by the name of the property?
You can use the function map that receives a function to iterate over the array, receiving as parameter the elements, just return the desired property, as this property is an array you need to…
javascriptanswered Costamilam 9,556 -
2
votes2
answers624
viewsA: What is the function of the <embed> and <Object> tags in HTML5?
According to MDN The HTML element <object> represents an external resource, which can be treated as an image, a nested browsing context, or a resource to be manipulated by a plug-in. The HTML…
htmlanswered Costamilam 9,556 -
1
votes4
answers686
viewsA: How to display the elements of an array where they are arrays?
Just put another loop inside the first: foreach($_SESSION['array2'] as $item){ foreach($item as $subitem){ echo $subitem; } } I used the foreach for being simpler, but can do with the for also…
phpanswered Costamilam 9,556 -
2
votes4
answers235
viewsA: Setinterval calling function only once?
The code is running what you asked it to do, adding a class to an element, but that doesn’t make the CSS styles accumulate, that is, two any elements, one with a class ativado and the other with two…
javascriptanswered Costamilam 9,556 -
3
votes1
answer69
viewsA: Do browsers cache the . htaccess file?
Not the browser nor has access to this file, it is a way to configure Apache on your server, what happens is that the browser makes a request to your server, for example: GET http://dominio.com And…
-
2
votes3
answers179
viewsA: Value of a variable becomes the id value
var x= 3; //Loop em todos os elementos da página for (const element of document.querySelectorAll('*')) { //Loop na lista de atributos do elemento for (const attribute of element.getAttributeNames())…
-
1
votes1
answer112
viewsA: Excess memory usage with timer in javascript
There’s a way to improve this code... Create references for elements outside functions, so they will only be created once Use recursive functions with setTimeout instead of using setInterval, can…
-
7
votes2
answers215
viewsA: What is the Javascript Cache class for?
The Cache API obviously serves to manipulate the application cache, usually implemented with service worker to intercept requests made by the application //Sempre que ocorrer uma requisição…
javascriptanswered Costamilam 9,556 -
0
votes1
answer601
viewsA: Contador Progressiva
Just add the tag script after the divs Use match to be separated three by three and the join to unite with the . Code: <?php date_default_timezone_set('America/Sao_Paulo'); $n = 180000; $cur_time…
-
12
votes1
answer1426
viewsQ: What is the Richardson Maturity Model?
In a question I asked about HTTP was commented on the Richardson Maturity Model, from what I understand, it serves to define how semantic your server is relative to HTTP (if you use verbs and return…
-
1
votes1
answer96
viewsA: Progress bar counting from 0 to widht set
In a simple but practically unfeasible way: @keyframes progress-content { 0% { content: '0 de 100%'; } 10% { content: '10 de 100%'; } 20% { content: '20 de 100%'; } 30% { content: '30 de 100%'; }…
-
2
votes1
answer84
viewsA: Connect time counter with the datetime of the database
The problem is the format of the date that is coming from the bank, you are getting in format aaaa-mm-dd hh:mm:ss and is treating it as if it were in format aaaa-mm-dd-hh-mm-ss, you need to convert…
-
0
votes2
answers100
viewsA: How to return a JSON block via request
Having the values in a variable resp just access the desired properties to take the values and use the innerText to set in an element: //Exemplo de dados respHT = [{ html: "HTML Básico", node: "Node…
-
1
votes3
answers650
viewsA: What is the best way to build a Mysql table with recipe items? All ingredients in one row or one ingredient per row?
The way you put it doesn’t make much difference, but separating the ingredients in another table can allow searching for ingredient considering the quantity, but in the table structure would have…
-
12
votes1
answer373
viewsQ: What are the Rfcs?
In questions related to HTTP protocol it is very common to see reference to one or more RFC... But what they are? Are only related to HTTP? Some are referenced as obsolete, which are the current…
-
3
votes1
answer3091
viewsA: Change element color with React
You can add classes using {}, for example: className={user.status} It is possible to concatenate with strings as well: className={'class-name-as-string' + user.status} // ou…
-
1
votes1
answer43
viewsA: want to create a struct of variable size and error program
The problem is that you are using the variable before initializing int opcao,codigo,quantVend,y; //Cria a variável y produto roupas[y]; //Usa a variável y y = 3; //Atribui um valor a variável y The…
-
0
votes3
answers45
viewsA: I can’t access the value
What happens is that when you create the variable pegarPeso the input value will be an empty string '', you do not need to create this variable, only the constant with the reference to the HTML…
-
0
votes1
answer347
viewsA: How to chain async functions in typescript?
The way it’s yours async and awayt do nothing and think they are even wrong. Also there is no reason to save the return of functions since they do not return anything You can pass a callback to run…
-
3
votes2
answers94
viewsA: Jquery event in the first input runs on all others
You can use the $(this).next(); to catch the next element // fixar descrição do campo var campo = $('.campo-formulario'); campo.on('input',function(){ var descricao = $(this).next();…
-
2
votes3
answers559
viewsA: How to know the type of a variable in Kotlin?
You can use reflection to do this: val widget = ... println("${widget::class.qualifiedName}") // Com o nome do pacote println("${widget::class.simpleName}") // Apenas o nome da classe To test a…
-
1
votes1
answer47
viewsA: Pdo passsa return vaizio in JSON
In PHP you can use fetchAll passing by PDO::FETCH_ASSOC to receive an associative array and then encode in json format: $ano_hoje = date('Y'); $janeiro_entrada = $conexao->query("SELECT…
-
1
votes1
answer164
viewsA: Error javascript code and cannot find
Missing add library jQuery, you can use this CDN: <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>…
javascriptanswered Costamilam 9,556 -
0
votes2
answers31
viewsA: Problems with Variables in JS
Supposing iLoop is an index that will be incremented and added to ids The this.id.substr(3) takes the barcode input id and removes the first 3 characters (cod) and the iLoop, then use it to select…
-
3
votes2
answers87
viewsA: Use mysqli_fetch_all in procedural mode
In procedural mode, the first parameter must be the result of mysqli_query Wrong: mysqli_fetch_all(MYSQLI_ASSOC) Correct: mysqli_fetch_all($sql, MYSQLI_ASSOC) As you said it works locally but not on…
phpanswered Costamilam 9,556 -
0
votes1
answer45
viewsA: Object Orientation Is my idea of connection correct?
Yeah, but you can get better, Every time you call this->conectar() to get a new connection, you create a new instance of the connection object with the database, then at a certain point in the…
-
1
votes1
answer158
viewsA: Creating a route system
The simplest way is through regular expressions, you must: Change string inside keys to ([^/]*) so any character other than / repeated 0 or will often be captured Use the function preg_match to…
-
1
votes1
answer846
viewsA: Cannot read Property 'Join' of Undefined
This is due to a typo, you wrote "enabled" instead of "skills" in the first item of the array In the function also has another problem, you are searching the "name" of each user but defined as…
javascriptanswered Costamilam 9,556 -
2
votes3
answers42
viewsA: Keep images online even on mobile devices
You should use some value take into account the width of the screen and not a fixed value, in this case I used the vw that considers the maximum value of the width of the screen (disregarded the…
-
0
votes2
answers79
viewsA: How can I insert javascript information into a json file
Basically what you want is to persist the data on the client side It is possible to save the data locally using Localstorage/Sessionstorage, Cookie or Web SQL, but will be saved only on the users'…
-
1
votes3
answers1025
viewsA: What types of data exist in Mysql for storing text and integer numbers?
If this class code has a specific size, that is, it will always have 6 characters, you can use the type CHAR, if it is of variable size, that is, it can have 4, 6, 8 or N characters, then use…
-
0
votes2
answers96
viewsA: Print user name on page
You can add a condition on the home page that checks for a logged in user: <?php if (isset($_SESSION['nome'])) { ?> <li class="dropdown"> <a class="dropdown-toggle"…
-
2
votes3
answers85
viewsA: Make item open when giving
I can think of two alternatives, Stick the menu and submenu and place the display: block in the Hover of the element span also: ul { display: flex; } li { margin: 15px 15px 0 15px; flex-basis: 50%;…
cssanswered Costamilam 9,556 -
1
votes2
answers613
viewsA: Nodejs - Mysql Error: Too Many Connections
What happens is that every time you invoke application.config.dbConnection(); a new connection is created with the bank, instead of exporting a function that creates a connection, create a…
-
9
votes1
answer2490
viewsQ: Does the REST standard allow the use of query string?
Most frameworks I know use URL parameters as follows: /recurso/variavel For example /produtos/{nome} /produtos/{categoria} Some use between {} others <>, etc. To differentiate the searches is…
-
2
votes1
answer142
viewsA: How to block access to a particular file on the server?
Through the archive .htaccess... If you want to redirect you can add this line: Redirect /caminho/para/arquivo.json http://dominio.com/arquivo/para/redirecionar.html If you want to block (403…
-
1
votes2
answers822
viewsA: Import data from a mysql table
You can do this only with an SQL query, I’ll leave an example: Table structure CREATE TABLE `tabela` ( `id` mediumint(8) unsigned NOT NULL auto_increment, `campo1` varchar(255), `campo2`…
-
0
votes2
answers2470
viewsA: Error: push is not a Function
Because there is no function push in an object, what you probably want is to add an item to the array, so you need to define listClient as an array: $scope.listClient = [];…
angularjsanswered Costamilam 9,556 -
1
votes4
answers199
viewsA: PHP Create dynamic array from one SQL and Separate by a specified amount of record in another Array
Simply, with a single loop, but two variables are required to store the indices, one is incremented every time with each iteration, the other is incremented by 6 in 6 iterations using the module…
-
23
votes3
answers4843
viewsQ: For a search with no results, should the HTTP response be 404, 204 or 200 with an empty body?
When we search for a resource on the server with some type of filter, for example, a user search, a list with the data is returned (in JSON, XML or even already formatted in HTML) But some searches…
-
4
votes5
answers6310
viewsA: How to stop the end='' command in Python
What happens is that when you change the value of end in the function, it removes the automatic line break because its default value is '\n' So print('foo') as well as print('foo', end='\n') writes…
-
1
votes2
answers59
viewsA: Call an arraylist from another method, to print in the different method
In function adicionar you do not add an item in the array, only overwrite it with an array of only one item (the new one, which should be added), plus the function has a loop that does nothing I…
phpanswered Costamilam 9,556 -
1
votes1
answer58
viewsA: How to avoid many "use" namespace resolution calls
You can just not use the use and put the full namespace when calling functions, creating instances, etc: namespace App\controllers; class Teste extends Controller { function index () { $config =…
-
0
votes1
answer446
viewsA: How to search for the lowest price in an entity with Spring Data JPA in a Jparepository? (Keywords or JPQL)
I don’t know much about JPA and the Spring ecosystem in general, but the cast error is because it defined a function like Optional<ItemVendedor> but in SQL returns min(iv.preco) who’s kind…
-
2
votes2
answers41
viewsA: Mysql not returning expected (using LIKE and EQUALITY)
If I understand, you want all the assets that have the title/description/value similar to the filter. So only the parentheses were missing: SELECT * FROM maq_dispo WHERE ativo = '1' AND ( titulo…
mysqlanswered Costamilam 9,556 -
0
votes2
answers1113
viewsA: Is it possible to generate a JSON file with Javascript?
First, connect executed in browser nay can touch anything outside the browser, for example manage files, all that is available for use is what the browser allows So if you want to create a system…
-
1
votes1
answer301
viewsA: Mysql structure in firebase/firestore
The structure of both (Realtime Database and Firestore) is more or less the same, so I will respond from one but that can be used for the other. Read the documentation for more details Documentation…