Posts by guijob • 1,809 points
65 posts
-
0
votes2
answers68
viewsA: I’m learning JS and was testing functions and have a doubt
When you set the detector function: function detector(){ var detector = txt.indexOf("!") if(detector>-1) return true } txt already has to exist in the scope of this function. Where you will call…
-
2
votes1
answer49
viewsA: Why do I get the message from Property is Undefined even with Arrow Function?
The problem lies in its function renderizarBotao. Inside it, you try to access this.aoClicarNota, but there is no this defined in the context of the function renderizarBotao. We need to define a…
-
1
votes2
answers137
viewsA: How to filter JS only with numbers and letters (no special characters)
A possible solution to this problem is to create new strings without these special characters. For this we can use a regex like /[^A-Za-z0-9]/g, that gives match on any character that nay letter or…
-
1
votes2
answers684
viewsA: Javascript - Separate a string and then add the values
Another way out is to use the reduce: '1994'.split('').reduce((sum, x) => parseInt(x) + parseInt(sum)) // 23…
javascriptanswered guijob 1,809 -
0
votes3
answers1186
viewsA: How to check each character of an array? Javascript
You can also use the includes: var s = 'an'; arrayOne.filter(x => x.includes(s)); // ["jean", "gean"]…
-
3
votes1
answer425
viewsA: What is Hoisting’s utility in Javascript?
Beware, this is not true. Not all variables of a function are created independent of JS scope. See: function x() { y = 1; var z = 2; } x(); console.log(y); // logs "1" console.log(z); // Throws a…
-
0
votes2
answers46
viewsA: How to create a clojure arrayList
You can use the split-Lines to do everything at once: (:require string :as string])) (string/split-lines "1\n2\n3") ; resultado: ["1", "2", "3"]…
-
1
votes2
answers929
viewsA: Difference between Arrays
You can also use the includes: listaLeituras.filter(x => !leiturasRealizadas.includes(x)); EDIT: As mentioned by Anderson Carlos Woss, the includes is experimental for the ES7 and may be subject…
javascriptanswered guijob 1,809 -
4
votes3
answers1206
viewsA: Statement "Return" does not work within foreach. Why?
All functions of the Array.prototype iteration, as forEach, map, reduce, filter and every, cannot be stopped. In each case, the value of the return is used for function-dependent decision analysis.…
javascriptanswered guijob 1,809 -
1
votes1
answer2549
viewsA: How to return an array in javascript?
I would like to add a few points: function loadImages () { let imgs = []; // se usar let não vai alterar nenhum imgs[] fora desse escopo // forEach percorre um array com o intuito de gerar…
javascriptanswered guijob 1,809 -
4
votes4
answers147
viewsA: I cannot use Boundary( b) to validate a word starting with "@"
Complementing the concept: The \b does not make selection. He is a anchor as well as ^ and $ and position the cursor to the positions that are between: (^\w|\w$|\W\w|\w\W). In other words: At the…
-
0
votes1
answer112
viewsA: How to upload this created data to an edit screen
Set a variable that will store the values in the controller and a counter: $scope.x = []; $scope.counter = 0; Now you need to put ng-model inputs. For this, you need to create html dynamically by…
-
0
votes1
answer55
viewsQ: Function changing the string
I wanted a function that received a string and returned another string with the characters offset 4 times. For example: "aaaa" returns "eeee" "amor" returns "eqsv" Thank you.…
javascriptasked guijob 1,809 -
2
votes5
answers3695
viewsA: Regular expression to find bar
A solution: str.match(/\w{2}\/\d+/g) \w{2} any letter (wOrd) 2 times \/ a bar / \d+ any digit (digit) 1 or more times…
-
0
votes2
answers290
viewsA: How to leave a number always negative in php?
I would rewrite your code with this function: function myFunction($classificacao, $valor){ if($classificacao==="A") $valor_final = abs($valor); elseif($classificacao==="B") $valor_final =…
-
1
votes1
answer76
viewsA: How to Recover Result from a Table in a Loop For
hello, below a possible solution: fill an array with length = 30 of the words you want: var names = ["João", "Maria"]; var array = []; for(var i=0; i< 30; i++){ array.push(names[Math.random()…
javascriptanswered guijob 1,809 -
0
votes2
answers40
viewsA: Take two "arrays" in one line?
That should work: Array.from(document.getElementsByClassName("teste")).map((ele, idx)=> idx === 0 || idx ===1 ? ele.removeAttribute("disabled") : ele); EDIT: The method getElementsByClassName…
javascriptanswered guijob 1,809 -
1
votes3
answers2243
viewsA: Doubt random string with Javascript
Call this function in "//here comes the logic of names". function pegaUmQualquer() { min = Math.ceil(0); max = Math.floor(1); return Math.floor(Math.random() * (max - min + 1)) + min === 0 ? "João"…
javascriptanswered guijob 1,809 -
5
votes4
answers1193
viewsA: Which DBMS to use so that it can be installed on the client’s computer to run a C#application?
Hello, since I had the need to create simple application in which the user did not need to use a bank and solved with the SQL Lite. It is a simple database that does not need to be installed by the…
-
0
votes2
answers59
viewsA: How to get elements from a different page?
According to the Wikipedia documentation, available at https://www.mediawiki.org/wiki/Manual:CORS: For Anonymous requests, origin query string Parameter can be set to * which will allow requests…
javascriptanswered guijob 1,809 -
0
votes3
answers333
viewsA: Help to filter a JSON with jQuery?
To solve the problem of the stretch[0], just force the filter to return true when the index is 0. Something like this: var filtrar = function (horamin, horamax) { var data =…
-
0
votes3
answers756
viewsA: Transform a Json Array into another JSON using Node
I never used underscore, but according to the documentation it would work if you applied so, considering resp as the return of SQL: _.groupBy(resp[0].itens, function(item) { return item.agrup; });…
-
2
votes2
answers50
viewsA: <audio> in hidden div
Try putting a id in your audio and do as follows: <audio id="myAudio" src="some_audio.mp3"></a> <div class="fig1"></div> .fig1{display:none} .evnt1{display:block}…
-
0
votes2
answers326
viewsA: nodejs, jsPDF and Windows
According to the documentation, the jsPDF is a package client-side. How are you working with node, then the package they recommend is the node-jspdf. For this I recommend uninstalling your jspdf and…
-
4
votes2
answers108
viewsA: If you are not checking the condition correctly
Let’s do the following: show plus decimal places of the mod and see if he really is 0.0. For that, I’ll use the library <float.h> and change your printf. The edition is arranged here:…
-
1
votes6
answers21461
viewsA: Format numerical sequence in CPF format with tabs using javascript
Edit your function as follows: function ValidaCPF(){ var ao_cpf=document.forms.form1.ao_cpf.value; if(ao_cpf.match(/\d/g).join('').length === 11) { console.log('cpf invalido.'); return; } var…
javascriptanswered guijob 1,809 -
4
votes5
answers2432
viewsA: Take the last position of a split()
Approach using regex: var nome = "Jose da Silva Sauro"; function replacer(match, m1, m2){ return m2.toUpperCase() + ', ' + m1; } nome.replace(/^(.+)\b(\w+)$/g, replacer); // "SAURO, Jose da Silva"…
javascriptanswered guijob 1,809 -
0
votes1
answer60
viewsA: Problems with Conversion of Array to Swift 3
Change: let json = JSON(value) For: let json = JSON(value) as! [String:AnyObject] You have to cast a JSON for the types you will handle in the code.…
-
-1
votes2
answers161
viewsA: How to round double values returned by Interface Location
As I suggested in the commentary: int indice = 0; // lat - latitude do cliente // lon - longitude do cliente double menorDistanciaAoQuadrado = Math.Pow(coordenadasPKs[i].getLatitude() - lat, 2) +…
-
0
votes2
answers922
views -
10
votes1
answer3650
viewsQ: What is the difference between virtual and Abstract methods?
In which cases should I prefer to use one type instead of the other?
-
3
votes3
answers3912
viewsA: Arduino IDE does not open in Windows 10 - JAVA error
To JVM not enough space in memory to execute. By log, is booking 256mb, so increase the memory. Perform the arduino_debug.exe with the flag -XX:MaxHeapSize=512m…
-
4
votes3
answers2680
viewsQ: How to iterate over a dictionary?
I have seen several ways to iterate over a dictionary. There is one considered standard?
-
13
votes1
answer28267
viewsQ: What is the Turing machine?
What is this such Máquina de Turing that made Turing be recognized as the "Pai da Computação"? How it works and how it reads a binary tape?
computer-theoryasked guijob 1,809 -
-1
votes3
answers1650
viewsA: How to highlight text (change color) in ANSI C
Depending on the Operating System, there is no implementation of the conio.h, basically depends on whether it was compiled into MS-DOS or not. Probably, the system you are using was not. In that…
-
0
votes2
answers54
viewsA: What function to use
If your value column is in A:A, starting with A2 fill in column B with: B1 = 1 and other cells, starting from B2 =SE(MOD((A2-53); 33)=0;B1+1;B1)…
-
15
votes0
answers176
viewsQ: What are the microservices?
A lot has been said about these microsserviços, it seems that they have come to replace the architecture SOA. Companies such as Netflix, eBay, Paypal and Twitter migrated their architectures…
-
0
votes2
answers249
viewsA: Translation SQL Script for Oracle
Try: v_DataExec timestamp(3) v_DataRef timestamp(3) v_DataExec := '20161008' v_DataRef := '20101205' Select Max - v_DataExec as DiasDiferenca, max(DatBase) as DataLimite, count(1) as Qtde_Registros…
-
1
votes2
answers68
viewsA: How to remove square parentheses from a scala array
Try this: def removerChaves(s: String) = s.map(c => if(c == '[') ' ' else c).map(c => if(c == ']') ' ' else c).trim val conf = new SparkConf(true) .set("spark.cassandra.connection.host",…
-
1
votes3
answers1779
viewsA: Many tables with little data or few tables with lots of data?
As you are working with relational model, I recommend doing the modelo entidade-relacionamento following the três formas normais and not add more tables than the model generates. As data grow,…
-
1
votes3
answers759
viewsA: How to style a select with Javascript only without Jquery?
Switch directly on select I think is not possible. But what you can do is turn this into a table and, from it, configure it to behave as if it were this combobox. HTML: <div…
javascriptanswered guijob 1,809 -
-1
votes2
answers1205
viewsA: How to envelop the Nfe shipment batch in the header using C#?
You can use CDATA: <![CDATA[ *texto aqui* ]]> In a XMLTextWrite the method writeCData(*xml aqui*) must be what you seek.
-
2
votes1
answer36
viewsA: Why does "is" not work when comparing the replace of a string?
The command is compares object instance references. If the two comparison terms are references of the same object instance then the is return true. Your comparison will return true if you use the…
-
2
votes3
answers257
viewsA: Show property value instead of class name in Datagridview
When Voce binds an object of a non-primary type, winform calls the Tostring method of that object. So, if you override the Tostring method of each of the classes you are showing (Category, Month,…
-
4
votes3
answers4535
viewsA: Why shouldn’t we use Singleton?
In general, the Singleton standard is generally not recommended because it is used in a manner wrong. Many devs end up using singletons in classes that are used in several places and/or often,…
-
6
votes2
answers177
viewsA: What is the name of the concept employed in this code?
In this example, in fact, you can’t tell if it’s an association or a composition. You would need to know if this Employee object is instantiated within the Company class or not. In composition: the…
-
1
votes1
answer1071
viewsQ: In Class Diagram, what is the difference between Boundary, Entity, and Control Classes?
I started to specify a project in UML and in the tool I am using has Boundary Classes, Entity Classes and Control Classes to make the Class Diagrams and Sequence Diagrams, what is the difference…
-
14
votes2
answers3182
viewsQ: What is the difference between Simple Factory, Factory Method, Abstract Factory?
What are the main differences between these design patterns? In which situation can one pattern be better than the other?
-
3
votes2
answers3831
viewsA: How to use vectors/arrays in Java?
Create a list: List<LatLng> pontos = new ArrayList<LatLng>(); pontos.add(new LatLng(-19.924312,-43.931762)); pontos.add(new LatLng(-18.851388,-41.946910)); Then recover by pontos.get(0),…
-
11
votes3
answers2015
viewsA: What is the difference between async, multithreading, parallelism and competition?
I wanted to enrich the discussion a little more and avoid confusion of theory: Processes, Threads and OS Process Scheduler, grossly speaking, is the mechanism organizes for how long which process…