Posts by mgibsonbr • 80,631 points
861 posts
-
31
votes2
answers1064
viewsQ: When to use Graceful Degradation and when to use Progressive Enhancement?
When creating a website or web application, there is always the problem of what to do when not all browsers implement all desirable features. From what I’ve read, there are two main ways to deal…
-
4
votes1
answer38
viewsA: Is it possible to configure a Jquery Effect?
You can choose the number of parts through the option pieces: $(elemento).toggle("explode", { pieces: 25 }); The number of pieces need not be square, but second the source code it will round the…
-
66
votes5
answers3667
viewsA: Is there any downside to always capturing Exception and not something more specific?
Generally speaking, it makes no sense for you to capture an exception if you don’t intend to treat it. Ideally let it "bubble up" (Bubble) for the same calling code, until some method is found that…
-
5
votes1
answer325
viewsQ: In a service-oriented architecture, is the database decentralized?
I’m with the prospect of taking on a big project, and by its own scale I suggested the adoption of a service-oriented architecture - because it is easier to solve several medium problems than a very…
-
2
votes1
answer315
viewsA: Collection Map<k,v> Methods
The difference between the put and the replace is that the put always associates the key to the value - even if the key did not exist before. O replace would then be a method of convenience, only to…
-
0
votes2
answers547
viewsA: Column problems in Python XLRD
Your problem seems to be in the form of progression of the loops: while curr_col < num_cols: curr_col = curr_col + 1 while curr_row < num_rows: curr_row = curr_row + 1 In the first iteration…
-
1
votes1
answer1218
viewsA: Searching for the next record and the previous record using two columns for sorting different tables
You first need to merge the two tables, and then establish the desired condition (same module and top/bottom position, or top/bottom module): SELECT * FROM lessons l JOIN modules m on l.module_id =…
-
2
votes1
answer2188
viewsA: Read rows and columns merged in excel, using python
The functioning of merged_cells is as follows: each entry in that list contains 4 values - the first row (top), the last row, the first column (left) and the last column. These lines and columns…
-
0
votes1
answer227
viewsA: Action Script 3.0 Function does not receive parameter
According to that thread, the method indexOf does not serve to search in an array, only in a string. var m: Array = ["CYCLE", "FREE", "EASY"]; // var index:Number; index= m.indexOf("FREE");…
-
5
votes1
answer128
viewsA: Take array name within array
That’s what you want? local n = 0 for k,v in pairs(a) do n = n+1 falas[n] = k end Example in the ideone. Source: that question on Soen.…
-
35
votes3
answers1568
viewsA: How does the licensing of Open-Source programs work?
Copyright According to the Berne Convention, certain works (mainly artistic and literary, but also scientific - including computer programs) have the copyright assured since their creation.…
-
3
votes2
answers117
viewsA: API Stackoverflow, "quota_max"
You need an API key to expand this number. In that reply you will see that with a key you can have up to 10,000 requests while the limit will continue to 300 if you do not have it. Sure, you can…
-
6
votes1
answer55
viewsA: Method resolution
According to the specification of Java, conversion rules are applied so as not to break compatibility with older versions - which did not support autoboxing or methods with variable number of…
-
3
votes2
answers136
viewsA: Problems in the implementation of methods
His method totalDePortas is almost good: the only thing left is this parameter casa. If the method already belongs to the class Casa - and you can access the object in question through the keyword…
-
3
votes3
answers391
viewsA: Doubt in Arrays - Beginner
Is this some exercise, or is it to be used in practice? If it is exercise, your problem is that when you create an array in empresa.criaArray(5) it will create an array with 5 positions, all of them…
-
1
votes3
answers2101
viewsA: How to put transition in a dropdown of a menu?
First, consider the possibility of a solution via pure CSS, such as pointed by dxhj in the comments. Just assign a negative margin to the submenu, and assign it to zero when the menu item is under…
-
29
votes3
answers10406
viewsA: How does HTTPS (SSL) work?
Edgar Muniz Berlinck already gave an overview, and the response of Onosendai describes the protocol very well, but I would like to complement it with the motivation behind the protocol (and make…
-
9
votes1
answer148
viewsA: Problem with C exercise
You are creating your vectors with zero size. So when you do: vetPrincipal[contador] = digitado; He’s trying to access a memory region that doesn’t exist. Try giving your vector a positive size (as…
-
6
votes2
answers917
viewsA: Check if parenthesis has been closed
If you have a number fixed in brackets (e.g..: 1 and only 1 - not zero or one, not one or two, only one) you can do with the following regex: [^()]*[(][^()]*[)][^()]* Otherwise it is impossible to…
-
4
votes2
answers1339
viewsA: Hide and Show all li decendentes of a ul - Jquery
Each ul is brother (sibling) of h4 clicked, and occurs immediately after it. To select it then, one can use next, and then proceed to search for their descendants: $("h4").click(function() {…
-
12
votes1
answer287
viewsA: What is the technology behind virtual machines?
TL;DR - no, JIT is a weight factor, but it’s not the only one that influences the performance of a VM-based program. Fundamentals In general, any computer program goes through several steps of…
-
12
votes2
answers6234
viewsA: How to check if a number is decimal?
If your number is in text format, the most guaranteed way to determine whether or not it is decimal is via a regex: texto.match(/^-?\d+\.\d+$/); That’s because I only use parseInt and parseFloat not…
javascriptanswered mgibsonbr 80,631 -
4
votes1
answer103
viewsA: Datareader blocks using Datareader "Close()"?
I’m assuming you’re referring to DbDataReader or one of its subclasses (e.g..: SqlDataReader), but you can adapt the answer if I’m wrong. Your first example is correct, there is no need to insert a…
-
4
votes3
answers129
viewsA: Simplify mouseenter and mouseleave of multiple images
You can use the function not to exclude a single element from a selector (in this case the this): $(".navHeader img").hover(function() { $(".navHeader img").not(this).css({ opacity:0.5 }); },…
-
7
votes3
answers1130
viewsA: Access negative index from an array
In Ecmascript (Javascript base and Actionscript) arrays are not "special" in any way: they are just a normal object with an attribute length. It means that: Internally, your keys are strings, not…
-
5
votes2
answers577
viewsA: What is `$. extend` and `$.fn.extend`for?
The function of extend is to copy properties of one or more objects to a target object. That is, it is a utilitarian function, which acts on "normal" objects, nothing specific from jQuery. var a = {…
-
8
votes3
answers13600
viewsQ: How to get the value of a column corresponding to the maximum of another column?
I have a table with columns codigo, data and valor. I would like to get, for each code, the value corresponding to the most recent date. In what ways can this be done? And if there is more than one,…
-
11
votes1
answer1796
viewsA: Exceptions in Java
Exceptions are a form of detour, as well as ifs, breaks, returns, etc. Its utility is to allow a code to be stopped if it is unable to continue, in a convenient and organized way. Suppose Java has…
-
2
votes1
answer3334
viewsA: Using Group By in SAS Guide
TL;DR - (Workaround) use Comments: select t1.nr_prpt_vcld as nr_prpt_vcld, (select t2.nrcvn_srvc from tabela_base t2 where t2.nr_prpt_vcld = t1.nr_prpt_vcld order by t2.ult_acl_atv desc limit 1 ) as…
-
1
votes1
answer116
viewsA: jquery sorts my date automatically
In Javascript, objects are ensembles key pairs/value. Sets, by definition, have no order. {1,2,3} == {1,3,2} == {2,1,3} etc. When printing on the console, an order is arbitrarily chosen (which, in…
-
4
votes1
answer162
viewsA: Code-golf - the description is the program
Prolog (38 lines) magic for. /* Defino minha mini-linguagem */ :-op(10, fy, [dado, um, vetor, com, no, qual, o, primeiro, eh, ultimo, intermediarios, sao, incrementos, do, seja, para, se, elemento,…
language-independentanswered mgibsonbr 80,631 -
2
votes5
answers4870
viewsA: Question on how to call the function with each mouse button
Your tela.onclick is simply reset to itself during the first click, so that every subsequent click will perform the same function every time. Example: // O mouse foi clicado com o botão esquerdo…
javascriptanswered mgibsonbr 80,631 -
9
votes2
answers396
viewsA: Licensing of Indie Games
It depends on what you call "a game made in Blender". Generally speaking, dice produced/processed by a program have no relation to its code. If you write a text in Word, for example, the copyright…
-
2
votes1
answer632
viewsA: Python problem
This is an executable python file (in the sense that it can be run. Obviously, it is a source file. A script, if you prefer). If it is in a file called exercicio.py, you can call him using: python…
-
4
votes3
answers2716
viewsA: Is it possible to create a MAP<> within another MAP<>?
Yes, it is possible. To access the second Map, simply get a reference for it (using the first key): Map<String,Object> interno = new HashMap<String,Object>() mapTESTE.put(primeiraChave,…
-
5
votes1
answer2819
viewsQ: Minimum bits required to represent a natural number
What is the most performative way to find the minimum number of bits needed to represent a natural number (i.e. no signal) in Javascript? There is a way to do without using loops? The code below for…
-
16
votes4
answers793
viewsA: Simple Teaching of Pointers
One way to see pointers is to make an analogy with names and addresses. Let’s say Alice lives at 42 X Street, Bob lives at 43 and Charlie at 44. If you only know Alice, but you don’t know or care…
-
2
votes1
answer810
viewsA: Value as Object when selecting item in Select2
Your problem is in function id: id: function(data){return {id: data.id};}, It should not return an object, but rather the value itself to be assigned to the hidden field (which by the way is Value,…
-
2
votes2
answers96
viewsA: Undefined is not a Function in Node.js using Mongoose
Its function saveUser wait 5 parameters. When calling it, you just passed 4. The 5th - callback - is therefore undefined, so that when you try to call it as a function it throws the error "Undefined…
-
5
votes1
answer183
viewsA: 2 regular expressions in 1
Yes, it is possible using lookarounds: (?=regex1)regex2 (?!regex1)regex2 In the first case (Positive Lookahead), the engine checks if the string matches the regex1, but without actually consuming…
-
29
votes2
answers8746
viewsA: Is Javascript interpreted or compiled at runtime?
Compiled at runtime. Like V8, the rest browsers introduced JIT Compilation to their Javascript engines to improve performance, some almost parallel to the V8 release (and others later): Internet…
-
5
votes1
answer277
viewsA: What is the return order of the attributes of the getelementbyid function?
Every DOM element, accessible via Javascript (is returned by document.getElementById either by other means) possess a property attribute that is of the kind NamedNodeMap. Translating freely from the…
javascriptanswered mgibsonbr 80,631 -
2
votes1
answer390
views -
1
votes1
answer883
viewsA: Return data from a JSON by sorting from a key
The first step is to create a list where each pair (chave,valor) is represented by an array: var jsonDecoded = { "241019846088038":{ "start_time":"20140815", "name":"Event 3" }, ... }; var pares =…
-
11
votes4
answers67145
viewsA: Composition and aggregation: what are the differences and how to use them?
In fact, there are no immediately visible practical implications of treating composition and aggregation as one thing. Personally, I never cared for that distinction. However, knowing whether a…
-
4
votes3
answers43625
viewsA: Regular expression that accepts only numbers and/or letters in Java
Usually the standard \w (word, word) box any letter, number and underscore (_). Thus, \w* would match a string with any number of such characters (including the empty string), and \w+ the same…
-
5
votes2
answers7594
viewsA: Send objects via socket
In theory, it is perfectly possible to write and read several serialized objects in the same stream. In practice, I remember having run into a number of problems in the past, and I do not remember…
-
10
votes1
answer4234
viewsQ: When to use RUP and when to use Agile?
What parameters should I use to determine whether a project will be more successful if conducted through a methodology Agile (Scrum, XP), or through the Unified Process (RUP, Praxis)? I can think of…
-
7
votes1
answer596
viewsA: Decompose huge number in javascript
Numbers in Javascript are doubles, that is to say, floating point with "double" (64 bit) precision. This means that the largest accurately representable integer is 2^53 = 9007199254740992 (larger…
javascriptanswered mgibsonbr 80,631 -
4
votes2
answers1540
viewsA: Jtextarea receives the append but does not display the text
When I click on a button, it has this call: Any code executed in response to a button click runs on Event Dispatcher Thread. This thread is used for virtually everything that interfaces with the…