Miscellaneous

Tone

A very nice example on how re-wording can really change the tone of something from this SO thread.

Change Had you looked at the error console, it would have informed you what the issue was, to If you look at the error console, it can tell you what the issue is, really does make a super difference!

Useful Utilities...

HTTP Methods

Idempotent

... aside from error or expiration issues ... the side-effects of N > 0 identical requests is the same as for a single request ... The methods GET, HEAD, PUT and DELETE share this property. Also, the methods OPTIONS and TRACE ...

This means that the side effect of a request is identical whether 1 such request is sent or a million! A side effect might be changing a value in a database or uploading a file, for example.

On thing to notice in the above definition is that POST is not necessarily idempotent! I.e., two identical POST requests may have different side effects than a single such request. You'll see why in the section on this method.

GET

... retrieve whatever information ... is identified by the Request-URI. If the Request-URI refers to a data-producing process, it is the produced data which shall be returned ...

GET is idempotent because the request can be made any number of times but the content on the server will not change. I.e. the side effect is the same whether 1 or many requests are sent (there are no side effects).

POST

... requests that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI...

"Subordinate" just indicates an "is contained/owned/part-of" relationship. E.g. a file is subordinate to a directory.

"Accept[ing] the enitity ... as a new subordinate" implies that whatever is POSTed is always added as new, which could, for example, be an append operation. Therefore, two such requests will not have the same side effect as one such event. In the former two objects could be added to, say, a list, and in the latter only one. Therefore POST need not be idempotent. In fact, one of the RFC examples is "extending a database through an append operation".

... The actual function performed by the POST method is determined by the server and is usually dependent on the Request-URI ...

In the POST request, and this is the reason for the non-idempotency, the URI identifies the resource that will process/handle the message contents. Because the processing is whatever the server likes, POSTs cannot guarantee idempotency, because the server can do whatever it likes with the message contents... all that was specified was the resource that operates on the contents!

PUT

...The PUT method requests that the enclosed entity be stored under the supplied Request-URI ..

In a PUT request, the URI identifies the entity in the request, i.e., the message contents. This is why idempotency is required. If we PUT the same uniquely identified thing many times, we should still have one uniquely identified thing!

DELETE

... requests that the origin server delete the resource identified by the Request-URI ...

Miscrosoft Word Shortcut Keys

A summary of MS word keyboard shortcuts.

TaskKey
Insert an empty field. CTRL+F9
Update selected fields. F9
Switch between a selected field code and its result. SHIFT+F9
Switch between all field codes and their results. ALT+F9
Change the selection to the Symbol font. CTRL+SHIFT+Q
Apply subscript formatting (automatic spacing). CTRL+EQUAL SIGN
Apply superscript formatting (automatic spacing). CTRL+SHIFT+PLUS SIGN
Remove paragraph or character formatting. CTRL+SPACEBAR

Root Sumsung S3 Mini

Had some problems getting Kingo Root to connect to my phone. It seemed the driver installation would constantly fail. I tried various drivers but the one that worked for me was found here at Android XDA. The driver for "Samsung Galaxy S3 (all variants)" was the one that worked. For some reason the one for "Samsung Galaxy S3" did not!

Having installed that driver Kingo Root worked as it promised :)

GCC Canaries

StackGuard: A compiler patch used to guard against stack smashing.

Agile

PMT() Formula For Mortgage With Offset Account

Mortgage repayments are "amortized", which means that the mortgage is payed off with a fixed repayment schedule in regular installments over a period of time [Ref].

Wikipedia has a good explanation for the formula used to calculate monthly amortized loan or mortgage payments. The formula, however, does not apply to mortgages with an offset account.

The following is based on the Wikipedia article. $F$ represents the balance of the offset account.

TODO

Fix FP

Fixed precision floating point we represent a floating-point number using $f$ bits for the fractional component and $i$ bits for the integer component, to make an $N$ bit fixed floating-point number. So for example if we used 4 bits for the integer component and 4 bits for the fractional component we'd write: $$ i_3 \ i_2 \ i_1 \ i_0 \cdot f_{-1} \ f_{-2} \ f_{-3} \ f_{-4} $$ The "dot" is "imaginary" in the sense that we just represent this as a series of bits. To the computer it's just an integer but we are "prentending" it is a floating point number. The unsigned floating point number above has the value defined by the following, as far as we're concerned. $$ i_3*2^3 + i_2*2^2 + i_1*2^1 + i_0*2^0 + f_{-1}*2^{-1} + f_{-2}*2^{-2} + f_{-3}*2^{-3} + f_{-4}*2^{-4} $$ However, as far as the computer is concerned this is just an integer with the value, $$ x_{i_3}*2^7 + x_{i_2}*2^6 + x_{i_1}*2^5 + x_{i_0}*2^4 + x_{f_{-1}}*2^3 + x_{f_{-2}}*2^2 + x_{f_{-3}}*2^1 + x_{f_{-4}}*2^0 $$ So, we get from the computer's idea of the value to our "imagined" decimal by dividing by $2^{4}$. More generally, if there are $f$ fractional bits, we are dividing by $2^{f}$.

Thus, to generically go from the computer's idea of an $N = i+f$ bit integer to our decimal value, we do this: $$ U(i, f) = \frac{1}{2^f}\Sigma{n=0}{N-1}2^nx_n $$ Note that this is for an unsigned type because the ${N-1}_{\text{th}}$ bit does not denote the sign of the value - the value is always +ve.

So, what about negative numbers? Two's complement! To the computer a signed N bit integer will have the following value. $$ \text{value} = -2^{N-1}x_{N-1} + \Sigma_{0}^{N-2} 2^nx_n $$ This formula, describing how two's complement works also tells us why we often see two's complement shown as a circle. When the most significant bit is set we are at the most negative number. As we add 1 we get less negative numbers until all bits are set and we have -1. Adding another 1 and we get zero (the addition overflows so the left-most bit which would have made us negative is lost) and so on...

So, if we are using $f$ bits for the fractional component we do the following to get the fractinal value. $$ S(i, f) = \frac{1}{2^f}\left(-2^{N-1}x_{N-1} + \Sigma_{0}^{N-2} 2^nx_n\right) $$

Using the fact that we are just dividing by $2^f$ we can easily determine the ranges of $U(i, f)$ and $S(i, f)$.

An unsigned number ranges from $0$ to $2^{N-1}$, so $U(i, f)$ must range from $0$ to $\frac{2^{N-1}}{2^f}$.