Posts by Samir Braga • 10,016 points
275 posts
-
8
votes2
answers1239
viewsA: How does the localCompare() method work?
Let’s go to the definition of the method: interface String { /** * Determines whether two strings are equivalent in the current or specified locale. * @param that String to compare to target string…
javascriptanswered Samir Braga 10,016 -
3
votes1
answer46
viewsA: format paragraph <p>
These breaks are about Text Nodes. See example below (Inspecione the paragraph element): const p = document.querySelector('p') const text1 = document.createTextNode('text1 ') const text2 =…
-
4
votes2
answers46
viewsA: Interpretation of Dive into Python on exceptions
To answer the first question, consider that you have a Python program with N functions F1 until FN. In which F1 throws an exception. Suppose also in your program, F1 is called within F2, F2 inside…
-
1
votes1
answer1981
viewsA: Local Data Storage with React Native
Take a look at the API Asyncstorage. Example: import { AsyncStorage } from "react-native"; let data_object = { data: '2018-08-01', local: 'Rua ...', humidade: 40, }; // Armazenando dados await…
react-nativeanswered Samir Braga 10,016 -
1
votes1
answer399
viewsA: Update object array in Mongodb with Node?
From your last image, I think this could solve: module.exports = async (id, data) => { await Bot.findByIdAndUpdate(id, { $set: { name: data.name, }, $push: { messages: data.messages, }, }); } In…
-
0
votes1
answer842
viewsA: Python, display index of a specific row within the matrix
Try this: matriz = [[5, 6, 347], [8, 9, 311], [12, 13, 20]] def getIndexOfLongerRange (mat): ranges = [max(l) - min(l) for l in mat] # Criar lista de intervalos return ranges.index(max(ranges)) #…
-
3
votes4
answers751
viewsA: How to create a <a> link without refreshing
Other option: <a href="javascript:void(0)" class="nada"> <img width="200"…
-
1
votes2
answers103
viewsA: Why does the number variable return an empty string when declaring it outside a function
Is that the way it is, you declare a new variable with the same name within the scope of the function printNumero() and the return, that is, its value is treated separately from the global scope.…
-
0
votes2
answers427
viewsQ: Free() in struct with char array
I have the struct struct data { int code; char name[50]; char feature[30]; }; typedef struct data Data; and the function: void free_data(Data *data) { if (data != NULL) free(data); } But the free()…
-
2
votes2
answers209
viewsA: Linter - Parsing error: Unexpected token {
The error is syntax, more specifically in this part: object =abc { def: lib.def, abc: lib.abc, xyz: 567, }; the correct would be: object = { def: lib.def, abc: lib.abc, xyz: 567, }; For you are…
javascriptanswered Samir Braga 10,016 -
0
votes1
answer58
viewsQ: Create different indexes for different searches - Mongodb
Hello, At another time I needed to get posts similar to a specific blog I’m developing, and this similarity was governed by the tags used in each post. Using Mongodb, I achieved this by creating an…
-
1
votes1
answer34
viewsQ: app.set('x-powered-by', false) does not work on expressjs
Hello, in my main code of my app, with the use of express, I’m trying to remove the "x-powered-by" header, and I’ve used so much app.disable("x-powered-by") how much app.set("x-powered-by", false)…
-
0
votes1
answer295
viewsA: res.redirect does not redirect in expressjs
I was doing the post from ajax and not from a form. With this, instead of user the res.redirect('route'), I just got the route from the server and used on the client side a window.location = route;…
-
0
votes1
answer295
viewsQ: res.redirect does not redirect in expressjs
I am the nodejs along with the expressjs and in the submission of a form a request is made on the server, which after processed, redirects the page: ... Post.create(doc, (err, post) => { if (err…
-
1
votes1
answer27
viewsA: Problems with encoding on static page
Problem solved, the hosting has an online file editor and as it was a small update, I used it. But he saved the file in some other I find that I didn’t utf-8. This time I saved it in Atom and went…
-
0
votes1
answer27
viewsQ: Problems with encoding on static page
I have an html file sent from a Node.js server that can be accessed here who is having trouble with accentuation. It was working normally, however, after a small update, it got this problem. When I…
-
3
votes1
answer28
viewsA: Why can’t you call CSS "pasted" classes
At first: .div1.div2.div3 { blablabla; } You are selecting an element that has all three classes, such as: <div class="div1 div2 div3"></div> In the second case you are working with the…
cssanswered Samir Braga 10,016 -
2
votes3
answers69151
viewsA: Vectors in Python
Python works with lists: lista = [1, 2, 3] Which are variants of size and of guy, independently. Unlike in the case of Array of some other languages. If you want to create a list with a predefined…
-
0
votes1
answer1403
viewsA: html & CSS - align inputs
Possible solution: .form-container span.input-label{ display: inline-block; width: 120px; /* width a ajustar */ text-align: right; padding-right: 10px; } <div class="form-container"> <span…
-
5
votes1
answer195
viewsA: Regex for python float validation
Try this: r"^([+-]?\d+)(\.\d+)?$" DEMO: https://regex101.com/r/Mq2buZ/4
-
5
votes6
answers300
viewsA: How do I transform an array that is in a string for javascript array?
Just one more alternative: var array = "['aaaaa', 'bbbbb', 'ccccc', 'ddddd']"; array = new Function("return " + array)(); // cria uma função retornando o array e a executa console.log(array); So…
-
2
votes0
answers84
viewsQ: Upload two files from two different Fields with multer
Using the ladies I am trying to upload two different files that comes from Fields in forms different and has different storage path also: let storageAudios = multer.diskStorage({ destination: (req,…
-
3
votes2
answers50
viewsA: Check type with jquery
Use a attribute selector: $("button[type=submit]").click(function () { $("form").submit(); });…
-
4
votes1
answer1028
viewsA: How to convert px to vh and vw in Javascript?
It’s just a matter of percentage: var convertPx2 = { vh: function(px){ px = parseFloat(px); var wh = $(window).height(); // captura a altura da viewport // faz a relação de porcentagem dos pixels…
-
0
votes1
answer165
viewsA: Capture my own number of followers
I was able to solve the problem by making the request via server using the module request with NPM, instead of doing by ajax. So no error.…
-
0
votes1
answer165
viewsQ: Capture my own number of followers
I’m trying to get a get of my follower number via Instagram API. I already own my clientId, mine userid and my accessToken. With the use of instafeed.js I can already access the feed. But whenever I…
-
4
votes1
answer166
viewsA: CSS architecture, could someone explain it to me?
I totally agree with Guilherme Nascimento, but although the question is a little broad, as this is a subject very little spoken and I find it particularly interesting, and I understand a little…
-
1
votes1
answer257
viewsA: Universal Selector Does Not Work
The universal dial * applies the style to all page elements, body, div, etc. However, as it is at the top of the page, quite probably, this style is being overwritten by the styles that follow it.…
css3answered Samir Braga 10,016 -
0
votes2
answers338
viewsA: Background does not work
The background is being correctly applied the problem is that if you inspect the element in which the background, you will see that its size is of 0x0. This is because all the elements within it…
-
1
votes1
answer129
viewsA: Class selector in CSS
I think the best would be to put all your styles that are not part of Bootstrap in a different file, and lynch it after all the links css. Just as: <link href="css/bootstrap.css"…
-
1
votes2
answers545
viewsA: How to update $Scope.items after push run?
I believe your function is for the button, "Update", so here’s a suggestion: I created the function updateItem, that takes as argument the update and the respective item to be modified. It goes…
-
4
votes2
answers94
viewsA: How to delimit the area of the ". Animate()" of jQuery?
My suggestion taking into consideration your current method of moving the doll: Give a position: relative in div.cenario: .cenario { /* ... */ position: relative; } Just like the doll has a…
-
5
votes1
answer68
viewsA: Animation div with Jquery does not recognize keys
Change the event of keyPress for keyDown that works perfectly: Note: The right is x.which and not x.wich: The basic difference is that the keypress recognizes the insertion of characters, or a…
-
5
votes1
answer448
viewsA: Division between integer and real number returns Nan
If the number coming from the text box is formatted with the vírgula representing the decimal, it will not work. In javascript, this role is the point .: You need to replace the commas by dots, and…
-
2
votes1
answer43
viewsA: Problem when installing Hiredis module
I was able to solve the problem with the following steps: I ran it at the prompt: set GYP_MSVS_VERSION=2015 npm config set msvs_version 2015 --global I created a Visual Project C++ file in Visual…
-
5
votes1
answer261
viewsA: Count vector elements and place links on the page
See if this works: Use a .map(), is an array function, similar to .forEach(), with the difference that the return of the function to each loop is what will replace the corresponding element in the…
-
6
votes1
answer126
viewsA: How can I make a New Year script?
Use the new Date() with the .getFullYear(), returns the year. If 2017, executes your code: var interval; function happyNewYear() { var date = new Date(); if (date.getFullYear() == 2017) {…
-
3
votes1
answer43
viewsQ: Problem when installing Hiredis module
I was installing the module npm Hiredis, but I had problems. According to your documentation, the only necessary prerequisite is the presence of Python 2.7 and of gcc / g++ 4.8, which I already…
-
3
votes1
answer46
viewsA: How to set two (or more) css parameters at once?
The most you can do is store the value in a variable: div { --size: 30px; width: var(--size); height: var(--size); background: #333; } <div></div> More about variables in CSS. Support.…
cssanswered Samir Braga 10,016 -
11
votes2
answers4047
viewsA: What are the main differences between JSON and BSON formats?
BSON (Binary JSON) is an extension of JSON, and was initially performed by Mongodb, a Nosql Document DB, which uses it to perform data storage. By storing data on Mongodb, you are already using…
jsonanswered Samir Braga 10,016 -
3
votes2
answers181
viewsA: Images in html or via css
I see two main issues to be taken into account: Semantics and Accessibility The use of tag <img>, through the attribute alt, generates an interpretation of the search engines, which influences…
-
1
votes1
answer1361
viewsA: Remove input field options of type datetime-local
With CSS - In Chrome You can put the whole typing field (::-webkit-datetime-edit), as 100%, which hides the button: input::-webkit-datetime-edit{ min-width: 100%; width: 100%; } <input…
-
0
votes1
answer42
viewsA: Phantomjs ignoring style in header
Try it like this: var res = page.evaluate(function() { var imageMapTags = ""; $(document).ready(function() { $('a').each(function() { var objOffset = $(this).position(); var top = objOffset.top; var…
-
1
votes2
answers1555
viewsA: How to get the bootstrap value toggle true or false?
Select the div and the input, as usual, with id or related. And to know if you are selected, just use .checked: $('#toggle1 input:checkbox').change(function(){ console.log("toogle one:",…
bootstrap-3answered Samir Braga 10,016 -
1
votes3
answers65
viewsA: Global function for plugin
Here is a suggestion: I found a generic way to do this, it works very simply: In function myPlugin you use the pure element and define a property to it called "myPluggin-Attached" with value true:…
-
10
votes1
answer2175
viewsA: What is the purpose of the "ready()" function?
The .ready(), as the Jquery documentation says: [...] offers a way to execute Javascript code as soon as the Document Object Model (DOM) of the page is ready to be manipulated. I mean, it’s an…
jqueryanswered Samir Braga 10,016 -
1
votes1
answer57
viewsA: Variable returning null only in Firefox
If your code is on <head>, it is loaded before the <body>. So, when you select an element outside of some event that guarantees the loading of the DOM, you will have as return null,…
-
3
votes2
answers3863
viewsA: Disable HTML5 Video Download Button
Hiding the button with a Blob By making a blob video and then a parse to URL (using URL.createObjectURL), Google Chrome automatically hides the button: var video = document.querySelector('video');…
-
1
votes1
answer242
viewsA: CSS alignment Cell table
The main thing is you set the line size line-height. This happens because this property already comes with a preset spacing, so just switch to the size that suits the cell: * { padding: 0; margin:…
-
0
votes1
answer94
viewsQ: $lookup no db.createView()
I have a database of two Collections: companies and people. And I want to create a view called "peopleSectors" from the collection people. db.createView ( "peopleSectors", "people", [ { $lookup: {…