Posts by dcastro • 6,808 points
128 posts
-
6
votes3
answers403
viewsA: What is the benefit of working with webSql?
I suspect the real question is: What is the advantage of using client-side databases? (i.e. webSql, or any other technology) Customer side comics (such as the Webstorage referred to by @utluiz)…
-
4
votes3
answers3924
viewsA: How to know the week of a given month?
I wrote this algorithm Calculate the first day of the current week (in my example, the first day of the week and 'Sunday'). Calculates the Monday and the Thursday of this week, and adds to' list…
-
2
votes2
answers3054
viewsA: How to use special characters in strings?
The symbol @, before a literal string, serves to avoid escape the special characters of the string. @"\server\pasta\arquivo.html" is equivalent to : "\\server\\pasta\\arquivo.html" The symbol @ can…
-
8
votes3
answers739
viewsA: What does ":-!!" mean in C language?
!! is double negation. It is a trick used in some languages to convert a result to Boolean. The first ! (from right to left) denies the expression (e) with an implicit cast for Boolean, and the…
-
4
votes4
answers13342
viewsA: Multiple lines of text or code with method ". html()"
So to complement: recommend the use of Coffeescript, a javascript processor (in the same way that SASS/LESS pre-process CSS). Cofeescript offers a much more convenient and readable syntax. One of…
-
7
votes6
answers15594
viewsA: How to do a search ignoring Javascript accent?
The accented letters are called diacritics. Here is a complete algorithm that searches and removes all diacritics (from various languages) of a string, keeping uppercase/minuscule letters: var…
-
13
votes4
answers2252
viewsA: What is the advantage of hiding the class constructor in favor of a static method (no .NET)?
This pattern is useful in rare cases. One is to implement the Singleton standard, in which the constructor is hidden, and a static method is used to create a new Singleton or return the existing…
-
3
votes9
answers2644
viewsA: Best practice for creating if
The best case isn’t A nor B. IS C: string mensagem; if(exibirAdeus) mensagem = "Adeus"; else mensagem = "OI"; In A: if displayAgod == true, 2 objects are created ("HI" and "Goodbye") if displayAgod…
-
4
votes3
answers595
viewsA: Responsive images
I used the picturefill on my website. Just include the "picturefill.js" file and mark the images like this: <span data-picture data-alt="A giant stone face at The Bayon temple in Angkor Thom,…
-
0
votes4
answers574
viewsA: Is it okay to store the password in a public class variable?
In a login system, passwords must be persisted (in a database, for example) after they have been hashish (for lack of better word) with a salt randomly generated for that user (as referred to by…
-
3
votes1
answer69
viewsA: Mismatch of . append with length
Usa $(".fotos > img").length to select all images whose parent has class photos. Your current code selects all images, then selects parent with class photos, and counts parents…
-
5
votes1
answer254
viewsA: What is a client-side Prepared statement?
The PDO driver is an abstract layer, and is not associated with any specific relational BD. This layer simulates client-side Prepared statements in case the server does not support Prepared…
-
27
votes7
answers44529
viewsA: How to get only the numbers of a string in Javascript?
function apenasNumeros(string) { var numsStr = string.replace(/[^0-9]/g,''); return parseInt(numsStr); } The simplest way: Use regex to delete all non-number characters. Make parse for whole Note…
-
1
votes1
answer41
viewsA: Deprecation Warning - Compass Unsemantic
There seems to be a compatibility problem between Unsemantic and SASS 3.3. In the link below, the author of Unsemantic states that Warning can be ignored without any problem. When SASS supports the…
-
26
votes6
answers32712
viewsA: Abstract Class X Interface
To complement Otavio’s response: Warning: inheritance (through abstract classes) should not be abused! Some people tend to abuse abstract classes with an aim in mind: reuse code, which otherwise…
-
6
votes3
answers12047
viewsA: Why doesn’t C# allow multiple inheritances?
Basically, because this would make it impossible to interoperable between languages through CLR (Common Language Runtime), because different languages define multiple inheritance of subtly different…
-
16
votes8
answers45010
views -
9
votes6
answers1227
viewsA: Property readonly . NET
Mads Torgersen (from the C#design team) announced that this is a Feature that is being considered for the next release (C# 6.0?). At present: private readonly int x; public int X { get { return x; }…
-
1
votes6
answers14692
viewsA: How to create a Git server on the internal network?
You can prepare your own git server using Gitlab or the Gitorious.
-
3
votes4
answers491
viewsA: How to get the name of the property to which a lambda expression refers?
public string AnalizarPropriedade<T>(Expression<T> expr) { var memberExpr = expr.Body as UnaryExpression; // parse da expressao "x.y" var operand = memberExpr.Operand as…
-
1
votes6
answers2251
viewsA: Upload files (always in different folders)
To ensure a uniquo name, just use a guid (globally Unique Identifier) to generate the folder name, and then store the file. string com_create_guid ( void ) Source:…
-
3
votes2
answers42348
viewsA: How to update/sync my repository master on github with the original master
You can use the Hub, To execute a pull request just use the command: git pull-request [-f] [-m MESSAGE|-F FILE|-i ISSUE|ISSUE-URL] [-bBASE] [-h HEAD] Source: pull-request manpage: You can also use…
-
1
votes7
answers16282
viewsA: Understanding the JSON file
The first example is a json array with 2 objects, each object has a title and a year. The second example is a simple json object with 3 properties (3 key pairs - value). I recommend a format similar…
-
13
votes3
answers74263
viewsA: What is the difference between the 'git pull' and 'git fetch' commands?
git fetch downloads the last commits from the remote branch, but does not embed them with the current repository copy. These commits are only available in the branch origin\master, and the branch…
-
0
votes2
answers384
viewsA: jQuery app works on Localhost, Mobile, but does not work on browsers
Not all browser compatible with events pageshow and pagebeforeshow. You can check this compatibility like this: if(window.onpageshow|| window.onpageshow=== null){ window.addEventListener('pageshow',…
-
47
votes6
answers98339
viewsA: How do I undo the last commit in Git?
Reset is only recommended if the last commit has not yet been sent ("pushed") to the server. Otherwise, undoing the last commit will invalidate the local copy. If you’ve already pushed, it’s best to…
-
11
votes3
answers2321
viewsA: Increment version automatically, and get version number via code
You can use an asterisk to "ask" Visual Studio to auto-increment the Assembly version [assembly: AssemblyVersion("1.1.*") The build number (3rd digit) corresponds to the number of days passed since…
-
7
votes7
answers9251
viewsA: In C#, what is the await keyword for?
First of all, I recommend reading this blog (in English) by Stephen Cleary: http://blog.stephencleary.com/2012/02/async-and-await.html Put in a simple way: From . NET 4.0, it is possible to…