Posts by talles • 11,434 points
64 posts
-
8
votes1
answer55032
viewsA: What is the difference and advantages of Opengl and Directx and when to use?
The big difference is 2D vs. 3D! The graphical part of the SDL gives an API to make 2D graphics, while Opengl provides you both 2D and 3D. Importantly, the SDL also provides several Apis in addition…
-
14
votes5
answers14658
viewsA: How to validate date taking into account leap year?
Another way is to check which month falls on February 29 (February 29 or March 1?). If it is February the year is leap: function anoBissexto(ano) { return new Date(ano, 1, 29).getMonth() == 1 }…
-
4
votes2
answers340
viewsA: Is it bad practice to use foreach inside the View?
Not! Bad practice is to carry out business rules in the view. Another very common bad practice is code repetition, copy and paste always the same code instead of creating a partial view. But, for…
-
0
votes2
answers351
viewsA: How to find the installation location of a package via SSH?
Try using the command which or whereis.
-
26
votes8
answers16426
viewsA: Why is using "SELECT * FROM table" bad?
"What problems are caused by its use?" The whole problem is that you’ll be (lazily) not specifying which columns you want from its clause SELECT: Inefficiency by quantity: You’ll be manipulating a…
-
2
votes3
answers229
viewsA: Good practices to avoid broken page display?
Your layout is made by images? If yes, one of the ways to circumvent this resizing while images are being loaded is to preset the image size. This allows the browser to already reserve the exact…
-
80
votes2
answers8108
viewsA: What are the differences between Dependency Injection and Control Inversion?
Inversion of Control (or Ioc, Inversion of Control) is a broader term to refer to a behavior (explained below). Several ways to implement inversion of control. Dependency injection is no longer…
-
4
votes3
answers905
viewsA: Problems with Double formatting
Thread.Currentculture As the staff said, the parse method will use the current thread culture to interpret/format the value. Changing the current thread culture is just a matter of changing the…
-
4
votes2
answers512
viewsA: Return of Xmlhttprequest connection
For active you mean if there has been any response? If yes, the correct way is using a time of timeout. The estate timeout of the Xmlhttprequest object accepts a number in milliseconds of timeout,…
javascriptanswered talles 11,434 -
11
votes6
answers19214
viewsA: Problem to publish project - Github
Hard to say with 100% certainty, but most likely the problem is that your local branch has a different name than the server branch (more precisely one of the two branches, the local or the remote,…
-
4
votes4
answers354
viewsA: Query about parameters and function call
Let me get this straight: you want to call a function (loaded preview!) whose name you have in string form, right? Just use the window object! Every function we simply call global in Javascript is…
javascriptanswered talles 11,434 -
9
votes2
answers660
viewsA: CDN vs. join JS/CSS
The solution depends on your scenario. Be guided by the amount of files your application uses. If your pages use many files (i.e., many requests are made), it tends to be more advantageous to keep…
-
12
votes8
answers5920
viewsA: Is it always guaranteed that a multi-threaded application runs faster than using a single thread?
Not. The parallelism can make your program run its role in less time, but there is no such guarantee. By the way, it may even be the other way around. In addition to the multi-threaded coordination…
-
7
votes3
answers1076
viewsA: Is anchoring a TR possible?
Unfortunately there is no specific construction for this. You will have to do "in hand". It is relatively simple to do with jQuery and data-* Attributes. Example: Javascript:…
-
10
votes2
answers1221
viewsA: Where should I declare an instance variable in Javascript?
foo is a variable only of the object you prompted, while bar is the prototype of the objects Spam (all objects). The difference is that in the first case each object has its own variable, while in…
-
44
votes5
answers9611
viewsA: How do Closures work in Javascript?
What is closure? Closure is a concept in programming language that, in a simplified way, allows a function to access variables from its parent function. This technique comes from functional…
-
19
votes2
answers5784
viewsQ: How to validate a Brazilian civil name?
How to validate people’s names, in Brazilian Portuguese?
validationasked talles 11,434 -
24
votes2
answers5784
viewsA: How to validate a Brazilian civil name?
The Portuguese alphabet is based on latin alphabet, consisting of 26 characters: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Added to these characters, the Portuguese alphabet (from Brazil)…
validationanswered talles 11,434 -
4
votes4
answers13879
viewsA: How to detect if an HTML element is empty?
Checking that it has no character (zero size): if ($('seletor').is(':empty')) Checking if it has no content (ignoring whitespace): if ($.trim($('seletor').html()) == '')…
-
16
votes2
answers2594
viewsA: What does it mean and how does an Enum work with the [Flags] attribute?
You can use operations bitwise to combine different values into one. To add a value use the operator: var rgb = Cores.Vermelho | Cores.Verde | Cores.Azul; To check if a value is present use the…
-
10
votes3
answers1977
viewsA: How to delete a file marked with the "Read only" attribute?
System.IO.File File.SetAttributes(caminhoDoArquivo, ~FileAttributes.ReadOnly); File.Delete(caminhoDoArquivo); System.IO.Fileinfo (via property) fileInfo.IsReadOnly = false; fileInfo.Delete();…
-
18
votes2
answers1727
viewsA: What is the function of the ~ (til) Javascript operator?
The operator ~ is the operator NOT binary (Wikipedia, MDN). Example: > ~ 5 -6 5 in binary: 0101. Reversing every bit we have: 1010, that is -6 decimally. Why -6? Remember the complement of 2!…
-
10
votes2
answers3614
viewsA: How do I convert the size of a file into bytes for KB, MB, GB, TB, etc?
Performance! For those who, for whatever reason, need this format to perform well just use constants and torque displacement operators (shift): public static string TamanhoAmigavel(long bytes) { if…
-
37
votes4
answers48488
viewsA: Where should I put a Javascript code in an HTML document?
Yes, it makes all the difference! Ground rule The basic rule is: most important scripts must come first in the document to run before, and less priority scripts may come later to make the most…
-
3
votes2
answers345
viewsA: How do I catch an error alert generated by the Google Maps API?
It seems there’s no way: If you analyze the gang Javascript minified will find there the alert, hardcoded. To page with documentation of authorisation problems doesn’t help much either. Someone in…
-
42
votes3
answers3888
viewsA: Why is using global variables not good practice?
Difficult understanding A variable makes more sense when declared and used next to the code that manipulates it. Often in a global context it is difficult to understand (completely) the role of that…
-
4
votes4
answers1488
viewsA: How to close a dropdown if the user clicks another page location?
$(document).mouseup(function (e) { var aEsconder = $('[seu seletor]'); if (!aEsconder.is(e.target) && aEsconder.has(e.target).length == 0) aEsconder.hide(); }); (source) Testing:…
-
36
votes8
answers14487
viewsA: How to create a copy of an object in Javascript?
Copy an object often not a simple task; there are different techniques with their respective pros and cons. It is especially difficult to offer a complete Javascript solution. Some have performance…
-
5
votes2
answers670
viewsA: What is the equivalent of Usercontrol in ASP.NET MVC?
What suits you is a Htmlhelper (Creating custom HTML Helpers). The two most common ways to create reusable components in ASP.NET MVC are partial views and html helpers. Unlike the views and partial…
-
4
votes1
answer954
viewsA: How do I convert a Datatable to a dynamic object?
For your first example in particular would suffice: dataTable1.AsEnumerable().Select(dr => new { ID = dr["ID"], Name = dr["Name"] }); But for a more generic solution the (little known)…
-
11
votes1
answer681
viewsA: Letter after a number, what is this called?
What’s the name of it? There’s no proper name for it, it’s usually referred to as suffix (suffix, Numeric suffix or suffix type). And where I can find a reference of the characters I can use? You…
-
11
votes2
answers2309
viewsA: Difference in Indice Unique and Unique Constraint usage in Sql Server?
In terms of performance and assertiveness the two are practically equivalent: A Unique index guarantees that the index key contains no Duplicate values and therefore Every Row in the table is in…
-
17
votes3
answers14753
viewsA: How do I remove a folder from Git’s history?
The answers are all right but... what is happening after all? The git commands may sometimes not be very friendly, here’s an explanation more human. On the basis of link script provided by…
-
4
votes4
answers3358
viewsA: How to create an element and after a few defined seconds remove it?
You can instead remove it immediately from the page, hide it in an animated way by controlling the animation time: $lblAviso = $('<p id="lblAviso">Salvo com sucesso</p>'); // cria o…
-
1
votes2
answers879
viewsA: How can I prevent a user from submitting the same form multiple times?
The simplest way is, via Javascript, to detect that the form was sent and disable the Submit button. Example (with jQuery): $('input[type=submit]').click(function(botao) { $(botao).prop('disabled',…
-
8
votes4
answers13910
viewsA: What is the best way to represent an Address?
I would like to know, from those who already have experience dealing with a large number of addresses, what practices would be recommended: leave everything normalized, use an open text field,…
-
25
votes4
answers8320
viewsA: What is the difference between client-side and server-side code in web development?
Server-side relates to the server side (your application server, e.g.: IIS). Client-side relates to the client side (e.g.: a web-browser). The interaction works as follows: Server Client User The…
-
22
votes4
answers15336
viewsA: In Git, how do I edit the description of a commit already made?
Editing the last commit Just do git commit --amend -m "nova mensagem". Editing a commit on the timeline If the commit you want to edit is not the last one you can edit via rebase interactive: git…
-
5
votes6
answers28585
viewsA: How to get Timestamp in Javascript?
As everyone said: new Date().getTime() Or else even simpler: Date.now()
-
7
votes2
answers3548
views -
23
votes3
answers20561
viewsA: How to create functions in jQuery?
$.fn.extend To extend jQuery (read plugin) there is the function jQuery.fn.extend(). Example: $.fn.extend({ alertar: function () { return this.each(function () { alert($(this).text()); }); },…
-
1
votes4
answers12949
viewsA: Return Array with name of all files in directory
Unable to access the file system via Javascript (in the browser). Already using the server side with Node.js it is possible. P.S.: One possible workaround would provide a page listing these server…
-
1
votes9
answers27569
viewsA: How do I read Javascript URL values (Querystring)?
I believe that most people looking for the answer to this question will be in the context of a web browser. But for those who are using Node.js it is worth remembering that there is a native…
-
14
votes2
answers2592
viewsA: How to optimize an image for web?
What image formats? One simple way to compress images is to use the namespace classes System Drawing.: public static void ComprimirImagem(Image imagem, long qualidade, string filepath) { var param =…
-
4
votes2
answers1709
viewsA: How do I implement the Groupby method in Typescript?
I don’t know if there is a Typescript way for this, but to solve your problem a Javascript solution would meet. Javascript pure var arr = [ { IDCidade: 10, Nome: "Foo" }, { IDCidade: 10, Nome: "Bar"…
-
8
votes2
answers2353
viewsA: How to get the integer value of one of the constants of an Enum?
If you’re manipulating the Enum in a way tipada, like the guy Nota, just a simple cast: public static void ImprimirNotaComoInteiro(Nota nota) { Console.WriteLine((int)nota); } Now, if you’re…
-
3
votes1
answer672
viewsA: How do I make Html.Labelfor() display an asterisk in required fields?
The only way I know how to do what you want is by writing your own helper, for example: using System; using System.Linq.Expressions; using System.Web.Mvc; namespace WebApplication.Extensions {…
-
16
votes5
answers2566
viewsA: Is it recommended to use Linq instead of SQL?
LINQ itself is a part of . NET that adds query functionality to the framework. Linq is not tied to any technology, he works on an interface (Iqueryable). The implementation of the final query (which…
-
5
votes3
answers227
viewsA: Is there a dialect of LISP/Logo in Portuguese?
Kturtle of The KDE Education Project (documentation). Kturtle is an educational programming environment that uses Turtlescript, a programming language loosely based and inspired by the Logo. The…
-
10
votes2
answers1505
views