Posts by luiscubal • 2,730 points
16 posts
-
19
votes1
answer7442
viewsA: Warning when trying session_start(); PHP
The error "headers already sent" means that information has already been sent to the customer at the time the line is executed. The session_start should be called at the beginning, before any HTML,…
-
5
votes2
answers281
viewsA: Yield Return inside a using
When called a method with yield, What it does is create an object of the enumerable type. The foreach creates a IEnumerator<T> through the method GetEnumerator. Usually, when the method has…
-
2
votes4
answers222
viewsA: Return null by breaking the code
equals is a method like any other. Just as x.foo(y) causes an exception when x = null, also x.equals(y) what makes. The correct way to check if an object is null is: x == null So in this case: if…
-
4
votes1
answer338
viewsA: Get value from XML
Try this: var nodeName = XNamespace.Get("http://schemas.microsoft.com/2003/10/Serialization/") + "boolean"; string value = xDoc.Descendants(nodeName).First().Value; What does this do: First we…
-
3
votes1
answer291
viewsA: $zero - What do you do and how does it work?
Type of instructions used (ld and dadd), I believe this is MIPS-64 (source who says that the dadd is present in MIPS-64). I have no experience with the MIPS-64 and I have worked little with the…
-
2
votes2
answers1930
viewsA: C# - Path to execution
In C#, it is possible get path to the program executable to be executed. string codeBase = Assembly.GetExecutingAssembly().CodeBase; UriBuilder uri = new UriBuilder(codeBase); string path =…
-
19
votes2
answers1480
viewsA: What is the function of operators <<, >> and >>> in Javascript
These are the operators of bit shifting. That is, operators who change the bit representation value by "pushing" it to one side. << pushes to the left and >> pushes right. The number 5,…
-
8
votes1
answer146
viewsA: Is there a specific type for passwords other than String in . Net?
The guy Securestring is described by the documentation as follows: Represents text that should be kept confidential. It is encrypted to privacy when it is being used, and erased from the memory of…
-
1
votes2
answers2621
viewsA: Javascript activating form action
By default, the <button></button> submit the form when pressing the button. This behaviour can be changed by indicating type="button" (jsfiddle). <button id="calcular_btn"…
-
30
votes3
answers27173
viewsA: How do I do an entire division?
Let’s start with a normal division: var result = 3/2; As noted, this operation has resulted 1.5, that’s not what we want. To have an entire division, we have to decide what kind of rounding we want…
javascriptanswered luiscubal 2,730 -
4
votes2
answers159
viewsA: div stops being updated in IE11
The problem is that Internet Explorer is checking that requests are repeated and therefore uses the cache. Apparently, he doesn’t do it the first few times, so it takes time to start failing. To…
-
10
votes3
answers671
viewsA: A C program can tell which OS it is compiling?
Directives of the Preprocessor: Windows: _WIN32 (which, despite the name, is also available in 64 bits) OS X (also includes iOS): __APPLE__ Unix: __unix Linux: __linux Android Linux: __ANDROID__…
-
3
votes3
answers3165
viewsA: Function to increment value within the div
The problem is that you are using the content of the widget to two effects: Save current value (valorInicial). Save the final desired value. When it reaches the line to change the innerHTML, it ends…
javascriptanswered luiscubal 2,730 -
5
votes4
answers4937
viewsA: Generate string securely random in PHP
When it comes to encryption/security issues, the ideal is to use tools made even for this. An example in PHP is openssl_random_pseudo_bytes, a function that was made to generate random numbers (with…
-
63
votes8
answers16873
viewsA: How to invert a string in Javascript?
Both Gabriel Santos' and mgibsonbr’s answers are wrong (although they work well in some limited cases that end up being the most common). Why are they wrong? Unicode. In ancient times (ASCII), each…
-
52
votes5
answers2194
viewsA: Exceptions consume a lot of processing. Truth or legend?
Yes. The. NET uses a processing model in which Try/catch is a "free" operation when there are no exceptions (which is the most common scenario), and the processing is moved to the throw (which slows…