Posts by vinibrsl • 19,711 points
378 posts
-
0
votes3
answers84
viewsA: Prevent link from opening while clicking and holding to drag in Google Chrome
You can use the attribute draggable and set it to false. This will prevent the link from being draggable. <a draggable="false" href="https://answall.com">Seu link</a>…
javascriptanswered vinibrsl 19,711 -
3
votes3
answers812
viewsA: jQuery is still "necessary"?
Why jQuery? jQuery was launched in 2006, at a time when the most used Javascript Apis were not 100% compatible among browsers. This jQuery compatibility layer ended up with that 90% of the top…
-
4
votes6
answers2057
viewsA: Modify the title of a browser tab with Javascript
Use the document.title. Remembering that will change the tag title in the GIFT also. document.title = "Novo título"…
javascriptanswered vinibrsl 19,711 -
6
votes2
answers1395
viewsA: How do I allow only certain applications to access my API?
Any type of key, token or security you apply will need to be applied on the client side as well. And that’s the big problem. When we are talking about a web application, there are easy ways to…
-
1
votes1
answer760
viewsA: Use of IIFE in ES6
When declaring variables with var no JS, it was necessary to create a new lexical scope not to mess up the window (in most cases). var abc = 1; console.log(abc); // => 1 console.log(window.abc);…
-
1
votes2
answers132
viewsA: How to block Numberbox or Textbox characters
Because there are different types of keyboard, and this validation is on the client side, it is not possible to cover 100% of the cases. So always keep your validations first on the server-side, and…
-
19
votes2
answers59817
viewsA: error: failed to push some refs
You’re trying to upload changes to a remote git, but on the remote server there are newer changes than yours, which you don’t have on your site yet. So before you push, you need to pull/pull the…
-
5
votes1
answer2022
viewsA: What is a view-port?
What is viewport? In computer graphics, the viewport is the visible area portion of a plane. What is the relationship that the viewport has with my web application? When we talk about responsive…
-
1
votes2
answers444
viewsA: while true x loop
Ruby is a language that allows different ways to the same end. The intention is to increase the semantics of the code, making it more readable. In the case cited, it is an infinite loop. The…
-
1
votes2
answers320
viewsA: What is the difference between a plugin and a Javascript library?
In a web context, I see these two terms being used differently. From the definition: The plugin is a type of intrinsic extension to the context. She can be used only in that context and cannot be…
-
3
votes2
answers87
viewsA: How do Orms, like Active Record, generate SQL code?
What is ORM? Simply put, an ORM is a technique for mapping database manipulations to objects in programming languages. One of the features of an ORM, as you mentioned, is to convert queries using a…
-
0
votes2
answers171
viewsA: Rails update to 5.2 error: The direct method can’t be used Inside a Routes Scope block
You have a call direct in your file config/routes.rb which is not allowed, being inside a namespace or scope. Is in the documentation: NOTE: The direct method can’t be used Inside of a Scope block…
-
7
votes3
answers236
viewsA: Check if array contains specific character
You can use a loop, combined with the Array.concat and a String.split to separate items with the pipe. const arrayOriginal = ["Tomate", "Abacaxi", "Carne|Fritas"]; let novoArray = [];…
-
0
votes2
answers220
viewsA: Nomethoderror: Undefined method `similaridade_com' for #<Class:0x007ff55873cad0> - Ror
You stated this method in the section private. That means that the method is private. Private methods can only be called by the recipient himself, the self. If for test merit, use the Object#send.…
-
0
votes2
answers440
viewsA: I don’t appear as a collaborator on a project I’m part of in Git
Github identifies by the commit author’s email. Run on your terminal: git config --list See if the output of this command has your email address, and which one is configured. This needs to be the…
-
1
votes1
answer344
viewsA: Permission of GIT files
I had this problem a while ago. I solved it this way: Open your local repository folder with Finder. Click the folder and press I. This should open the folder information. If a padlock appears in…
-
8
votes1
answer105
viewsA: Why does Ruby have two send and __send__methods?
Given that dynamic modifications such as method superscripts are common to see in Ruby, the Object#__send__ and Object#send is a way to protect objects against overwriting. The __send__ serves as an…
-
2
votes1
answer295
viewsA: Issue does not close after commit with Issue referenced "Issue #1 Fixed"
This is a Github feature. It has a close issues feature from the commit message. As far as I know, it reads the commit description, not that main message. For example: Adiciona foo ao módulo bar…
-
8
votes1
answer3444
viewsA: .gitignore com . env
When the file is in the staging area and you add it to the .gitignore, it is not removed. For this, do: git rm --cached .env What this command will do, because of the flag --cached, is to remove the…
-
0
votes1
answer272
viewsA: Compare remote repositories
git diff remote1/branch remote2/branch file.rb Being remote1 and remote2 the name of the remote repositories, and branch the Git branch you want to buy. See the documentation of git-diff.…
-
3
votes1
answer80
viewsQ: How can a class also be a method in Ruby?
See the class Integer: Integer.class => Class It also seems that it is a method, at the same time that it is a class: Integer 10.5 => 10 How is this possible in Ruby? Where is this method…
-
1
votes1
answer78
viewsA: Access a hash/list in a class
The problem is that you assign @contas within the scope of the class. In Ruby, scopes are very important. See the following example: class Carro attr_accessor :modelo, :ano def andar puts 'Estou…
-
2
votes1
answer170
viewsA: Method of login in Ruby
Before you start, remember to always follow the guidelines and language conventions, especially when using the Ruby on Rails framework, which is known for the design paradigm Convention over…
-
7
votes1
answer3271
viewsA: What are environment variables?
What are environment variables? When a program is run, it receives information from the environment in which it is running. This environmental information is implicitly passed via environment…
-
0
votes1
answer23
viewsA: Method returns me as null
In the controller, you must have a action pointing to this view. There in the action, @task needs to be instantiated. See: def new @task = Task.new end…
-
5
votes1
answer402
viewsQ: What is a fault tolerant (fault tolerance) system?
When talking about high-scale systems, much is heard of having a fault-tolerant system (fault-Tolerant). See the description of the Elixir programming language: Elixir is built on top of the Erlang…
-
3
votes1
answer53
viewsA: Doubt about events in a Javascript function
Your Javascript application is reactive to HTML events. That is, when the user clicks a button, you can add a Handler to define some behavior when this button is clicked, for example, make an HTTP…
javascriptanswered vinibrsl 19,711 -
0
votes1
answer22
viewsA: TAB autocomplete does not work with NPM
The Completion npm in your shell does not come from factory. For this, npm recommends the npm-Completion. It is already native to npm, you just need to call it at the startup of your shell. Add the…
-
1
votes1
answer149
viewsA: How to checkbox validation in Ruby on Rails?
Rails has a validator called acceptance_of. It is used when you have a boolean and want to check if this value is true. class Person < ApplicationRecord validates :terms_of_service, acceptance:…
ruby-on-railsanswered vinibrsl 19,711 -
3
votes1
answer580
viewsA: Do v-for only with number
You can use the v-for with a range. For example: <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <div id="range" class="demo"> <select> <option…
-
1
votes1
answer5594
viewsA: The python programming language can be used together with html
The answer is yes, but with reservations. Python is a programming language like Javascript. The difference is that browsers have javascript engines, and can interpret at least HTML and CSS.…
-
1
votes2
answers202
viewsA: How to create a Ruby On Rails application (not just an API) and provide some routes as an API
You can run the rails new without the flag --api. So you keep Action View and everything. Then you will have an API layer and an Asset Pipeline layer, the Rails standard. To create this API layer,…
-
0
votes2
answers226
viewsA: Rendering a JSON object with the merging of different models
Activemodel::Serializer allows you to have multiple serializers for the same model. class SimplePartSerializer < ActiveModel::Serializer attributes :id, :name end class ComplexPartSerializer <…
-
4
votes2
answers694
viewsA: What are semantic messages in Git?
The semantic commits as you described were proposed in an Angularjs convention document. They have been documented and widely used by Karma, a project open source testing for Javascript. Today, many…
-
1
votes1
answer184
viewsA: How to Import Classes from Another Package
Ruby does not work with packages, but rather files. The methods that control this are the Kernel#require and the Kernel#require_relative. The Kernel#require always asks for absolute paths to the…
-
0
votes1
answer184
viewsA: How to put a . Gem in Gemfile
The problem is occurring because it is pointing to a file .gem, and it must be unpacked. Therefore: gem unpack my_gem.gem --target app_path/vendor/gems After unpacking, just refer to the Gemfile:…
-
3
votes1
answer3073
viewsA: How to validate mobile and home phone?
You can use a regular expression. It is a string that defines a search pattern. It is an algorithm. We can say that it is a language for localization of patterns in text. See: What is a regular…
-
1
votes1
answer86
viewsA: How to parse from one object list to another?
You can use the Array.prototype.filter() to filter items from an array. const items = [ {'title': 'Entregar relatório', 'note': '', 'image': '', 'status': 'aberta'}, {'title': 'Fazer compras',…
-
1
votes1
answer283
viewsA: Computed v-for Vuejs
You are using computed properties wrong. Think about computed as a read-only property. See the example below: <div id="exemplo"> Mensagem ao contrário: {{ mensagem.split('').reverse().join('')…
-
10
votes7
answers78990
viewsA: How does this if/Else work with "?" and ":"?
Ternaries, binaries and unary Ternary, of the Latin ternarius, means "composed of three items". Ternary operations, whether in mathematics or in computer science, are those that have three operands.…
-
1
votes1
answer740
viewsA: How to blur image in css without leaking?
You can use two images, one with Blur and another without, with a div to insert your text, see: .conteudo { width: 70%; height: 70%; border: 2px solid; border-radius: 20px; position: fixed; top:…
-
4
votes1
answer33
viewsA: displayed result exceeding the condition
The 14 that is displayed is not your product console.log, and yes the result of the last statement of while. See what happens when you add the results into an array: var num = 0; var numbers = [];…
javascriptanswered vinibrsl 19,711 -
0
votes1
answer386
viewsA: Gems autocomplete in text editor
All the dynamism of Ruby complicates the autocomplete. So much so that the rubistas are already accustomed to not having a tool of code Completion as has Java and C#. When there is no language…
-
7
votes3
answers1699
viewsA: Why doesn’t "= NULL" work?
The NULL is the undefined, undetermined and indefinable. It is not false, but neither is it true. Neither 8 nor 80. It is not a value, but the lack of one. Because it is not a value, it can be…
-
1
votes2
answers56
viewsA: Rails - query for non-connecting records
To leave a little more "Rails", performative and avoids any type of SQL Injection, I give you an alternative to reply by @Danilo. user = User.first user.notifications…
-
1
votes2
answers493
viewsA: belongs_to, has_many
In Active Record, associations function as connectors in memory of objects. There are different types of associations: belongs_to, has_many, has_one, has_many :through, has_one :through and…
-
1
votes1
answer559
viewsA: Why does this 'sys' is not defined error occur?
The module sys is not set at runtime as it has not been imported. At the top of your code, add: import sys Documentation of import.…
python-3.xanswered vinibrsl 19,711 -
23
votes2
answers5722
viewsQ: What’s wrong with the N+1?
Whenever we work with some ORM, it is common to fall into the problem of darlings N+1. It’s something about performance, called even antipattern. But what is really this problem, why it happens,…
-
1
votes1
answer160
viewsA: Make two queries in the same table in Mysql
Your question has become a little broad, but leaving the principle that you already have this form ready, that the city selected on the site is persisted in memory and that being with the expired…
-
6
votes1
answer120
viewsA: Why can’t I see the icon code ( ) in developer mode?
For this case, the Unicode standard is used (note that is not a encoding). Simply put, it is a key and value mapping between characters and their Unicode codes (or code points). Just like in the…