Posts by mgibsonbr • 80,631 points
861 posts
-
6
votes1
answer1563
viewsA: Perfect forward secrecy, what is it?
In encrypted communication (for example, via HTTPS) the client and server share a secret - called a "session key" - which is responsible for ensuring the confidentiality of communication. Anyone who…
cryptographyanswered mgibsonbr 80,631 -
3
votes1
answer1935
viewsA: JSONP: status code 200 OK and still returns $.Ajax(...error:Function()...)
JSONP is different from JSON. JSON is a data serialization format, when you make a request waiting for a JSON the server must return text content. And in fact, that’s what your server is returning.…
-
2
votes1
answer181
viewsA: Interpretation, Mtproto Encryption
Disclaimer: the text you refer to is a description of what the protocol does, without indicating the motivation behind it. This response follows in the same line. According to this diagram in…
-
4
votes2
answers153
viewsA: Chosen-ciphertext Attack what’s it like?
The Chosen-ciphertext Attack ("chosen cipher attack") can refer both to an attack on an encryption system undocumented (i.e. that only cares about the confidentiality but forgets the integrity and…
cryptographyanswered mgibsonbr 80,631 -
7
votes8
answers5853
viewsA: Recognize word repeats in String
A very simple solution*, using split and two sets: public static String marcarRepetidas(String s, String prefixo, String sufixo) { Set<String> palavras = new HashSet<String>();…
-
3
votes3
answers1207
viewsA: What’s the difference when calling a function with parentheses and without in.py urls with Django 1.7?
When you associate a URL to a view you are not calling the function of view - only indicating which function should be called when someone visits that URL. In other words, when doing: url(r'^$',…
-
5
votes5
answers14567
viewsA: How to access index from a javascript array
If an array (and not only an object) has non-sequential numerical properties, the "size" of that array (i.e. its property length) is one more than its largest non-negative index. If your array has…
-
6
votes2
answers257
viewsA: Restrict object method override in javascript
You can use Object.defineProperty so as to have greater control over the characteristics of your method (or field). For example, to make your method read-only, assign writable as false: var object =…
-
6
votes3
answers2621
viewsA: What is end-to-end encryption
To maniero’s response already explains what it is end-to-end, I will only complement by addressing your specific questions: She is inviolable? Nothingness is inviolable. Only by way of example: If a…
-
23
votes2
answers500
viewsA: Does data received from HTTPS come encrypted?
SSL/TLS is a transport-level encryption layer. This means that: Yes, the data arrives encrypted; only the browser user and their server have access to them, no one in the middle of the way can see…
-
33
votes4
answers9005
viewsA: Why is HATEOAS important?
The characteristic HATEOAS is, in the words of its author, "design on the scale of decades" and "many of its restrictions are directly opposed to efficiency in the short term". That is, it is…
-
4
votes1
answer209
viewsA: Get Rows that are not from the logged-in user
From what I understand, one of the ids (de or para) must be the one of the logged in user, and the other not, and you want the other in either of the two situations, right? There are several ways to…
-
34
votes4
answers2538
viewsQ: Should exceptions be used for flow control?
When I studied Java, I learned that exceptions should only be used in situations, well, "exceptional" (i.e. an error, an unforeseen condition, etc), never for normal flow control. Not only because…
-
2
votes3
answers7043
viewsA: How to make a left Join using a Where condition?
Your problem is that the clause WHERE deletes lines that do not have the specified user. To resolve this, move the desired condition (user "x") to the clause ON: SELECT c.id, nome, imagem, u.id AS…
-
2
votes3
answers133
viewsA: Regex capturing it all
Your problem is that the quantifier * is greedy, Which means he’ll marry as much of the down payment as possible before he quits. If you want it to marry as little as possible, you can use its lazy…
-
5
votes1
answer1621
viewsA: What are web Workers and how to use them
In fact, a Web Worker is similar to a thread separate from the principal. However, it is completely isolated from both this and the DOM (i.e. the "View"), so that the only form of communication…
-
25
votes5
answers41788
viewsA: How to sort an array of objects with array.Sort()
The method sort accepts as parameter [optional] a function with two parameters - two objects to be compared by the sorting algorithm. This function must return a negative number if the first object…
javascriptanswered mgibsonbr 80,631 -
54
votes8
answers13920
viewsA: Is <br> or <br/> or <br />right?
HTML has always used <br> only and - more generally - <tag> and ready whenever an element is considered "empty" (i.e. it cannot receive sub-elements). However, with the advent of XHTML…
-
5
votes2
answers15519
viewsA: Indefinite reference of functions
I think you’re confusing the concept of "linkage": it’s not the source and the header that are linked, and yes multiple files object link to each other to form the executable (or library/dll). The…
-
4
votes1
answer982
viewsA: Error searching in Sqlite
In Java, one exception can cause another, the other cause, etc., so it is necessary to search for the root cause of the error. In stack trace this is shown via Caused by: ...:…
-
4
votes1
answer103
viewsA: Possible bug input number in firefox
Apparently, by calling the method reset form the value of the numeric field is not considered "changed", so that when you pass it again to 1 through the arrows, it does not fire the event onchange.…
-
7
votes3
answers4422
viewsA: How to toggle text between "show / hide" inside a javascript button
All you need to do is select the button (give it a id to make it easier) and change its value (innerHTML) during the code of onclick: function Mudarestado(el) { var display =…
javascriptanswered mgibsonbr 80,631 -
6
votes2
answers212
viewsA: Why Arraylist instead of Stack in the implementation of the Memento standard?
In Java, classes that inherit from Vector (including Stack) sane thread-safe, that is to say: they carry the overhead to prevent two threads access at the same time the same collection. The use of a…
-
2
votes1
answer573
viewsA: How to dynamically update a listing
First, when adding an element check how many are already there: function adicionaItemPedido(){ cont = $("#table_itens tr").length + 1; ... Then, when the user clicks on a remove button, update every…
-
6
votes2
answers3468
viewsA: Best route calculation algorithm
This is a problem of minimum path, unidirectional believe (the distance from A to B is the same distance from B to A) and no negative weight (the distance is always greater than or equal to zero).…
-
11
votes1
answer1769
viewsA: Compressing data with Javascript
The library lz-string seems a good option to compress strings via pure Javascript: var string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore…
javascriptanswered mgibsonbr 80,631 -
17
votes1
answer2607
viewsA: What are the main differences between a quantum computer and a conventional computer?
In a conventional computer, a given data (i.e. a "bit") is always in a single state - 0 or 1. In a quantum computer, this same data (called "qubit") can be in any overlapping of these two states,…
computer-theoryanswered mgibsonbr 80,631 -
11
votes1
answer1783
views -
6
votes2
answers316
viewsA: Can I use MIT along with GPL?
The MIT license is compatible with the GPL license, so there is no obstacle to having a system with some components under one of these licenses and others under the other. The question is what is…
-
4
votes1
answer160
viewsA: Show message when filter does not find output
My first suggestion is to create an item for "no results" and put it together with others. Give it a special class so that it is not visible along with the others (as long as there is no filter, for…
-
5
votes3
answers249
viewsA: How do you make sure the person who used the system is really her?
and if anyone asks for any proof that it really was he who granted such an inscription? The name of this feature you seek is non-repudiation (non-repudiation). It is one of the features that…
-
7
votes2
answers705
viewsA: How to calculate hash?
A torrent file has a data structure with two higher-level keys: announce - identifying the(s) tracker(s) to be used for download - and info - containing the names of the archives and the relevant…
-
8
votes1
answer470
viewsA: What is the difference between using the class method and the Javascript prototype?
If there are few objects, it does not matter, but if the number of them is large, put in the prototype has the advantage that only one copy of the function exists, not several (functions are first…
javascriptanswered mgibsonbr 80,631 -
5
votes4
answers542
viewsA: Subsequent Calls in Ajax
Assuming that all its elements are brothers (various lis for example, or rows of a table) you can make the call ajax in the first and - when completing it - pass next pro until no more: $("#meuid…
-
6
votes3
answers1181
viewsA: Passing vector to functions
In C you cannot pass vectors by value, only by reference (i.e. you need to pass a pro vector pointer, not the vector itself). However, the C syntax allows you to define your function in this way:…
-
6
votes1
answer1855
viewsA: Equation solving
If after the replacement of x the result is an equation up to 2 degrees in y, then it can be solved by Bhaskara’s formula: a*y^2 + b*y + c = 0 y = -b +- raiz(b^2 - 4*a*c) ----------------------- 2*a…
-
2
votes1
answer122
viewsA: Make large-scale textContent exchanges with Javascript
If you are generating a page with PHP, where the click on an element (or some other action) should fetch other results on the server, the first thing to do is specify what should be sought. I…
-
4
votes1
answer330
viewsA: Can enumerations contain methods?
In Java, an enumeration is nothing but that a class either inherits [implicitly] from Enum. The number of instances of it is fixed, and it may or may not be abstract - the important thing is that…
-
2
votes1
answer171
viewsA: Chart.js update method displays "bar.save is not a Function" error
According to the documentation, the correct way to update a value on the bar graph is: myBar.datasets[0].bars[0].value = 10; myBar.update(); The way you’re doing it, it’s not the value of bar that…
javascriptanswered mgibsonbr 80,631 -
5
votes2
answers2734
viewsA: Regular expression to retrieve strings starting with colons (:)
The expression suggested by Sergio in the comments seems to be the simplest way, saved by " (that was not mentioned in the question), and the missing blank (as pointed out by Gustavo Cinque in the…
-
78
votes3
answers51454
viewsA: How does the AES encryption algorithm work?
AES is a cryptographic primitive intended to compose symmetric encryption and decryption systems (i.e. the same key to encrypt and decrypt). It is a block cipher, that is, it operates in blocks of…
-
4
votes2
answers151
viewsA: Include class as link
You can do this only with CSS: .homeNoticiasOpacidade { width: 100%; height: 100%; background-image: url("../imagens/engenhariaPNG.png"); top: 0; position: absolute; z-index: 2; background-repeat:…
-
25
votes2
answers2433
viewsA: What is Javascript Prototype?
If you’ve read it the technical part and continues with doubts (and from what I understand has no experience with programming other than JS), I’m going to go down to the basics. I will try to be…
-
1
votes1
answer264
viewsA: Error with Actionlistener
Its variable bDialogo it’s not a button, it’s a label ("label"). Labels only serve to display information, there is no action associated with them (such as clicking action). You are calling the…
-
1
votes1
answer789
viewsA: How to generate a username with its real name as a reference?
My suggestion is to first assemble the name "radical" (the part before the number) and then use a counter to determine the most appropriate suffix (if any): radical = ''.join(x[0] for x in…
-
3
votes2
answers193
viewsA: When to use Em or %?
The units em and ex are relative to the font size. ex is the height of the tiny "x," and em is simply the "font size" (the unit name comes historically from 'the width of the capital "M"', but this…
-
3
votes3
answers144
viewsA: How to play items with a specific value for the beginning of an array?
You can create a new sorting function that makes use of the first: perguntas = perguntas.sort(function(a, b) { return a.inicio > b.inicio ? -1 : b.inicio > a.inicio ? 1 : comparadorAntigo(a,…
-
1
votes1
answer173
viewsA: How to use Consumer in a variable (Java 8)
In Java 8, a Functional Interface is any interface which has exactly 1 abstract method (it can also have standard methods, or declare abstract methods of Object, but needs to have 1 abstract method…
-
12
votes4
answers15696
viewsA: How to extract digits from a Python string and add them together?
In Python, you can iterate on a string as if it were a list: >>> for ch in string: ... print(ch) ... 9 6 h 1 1 k In the loop above, with each iteration ch will be a string 1-character. To…
-
5
votes2
answers262
viewsA: Tag header, daughter of tag Section, inherits values from other tag header
One solution would be to give the first a class header: <body> <header class="header-principal"> </header> .header-principal { ... } Another would be to use the child selector so…