Stretchly – Helps You Reduce Back and Neck Aches

Stretchly is a PC software that reminds you to do breaks. To rise, to move every so and so minutes. And I have to say, it really helps us computer workers who are staring on a screen all day to put in little breaks to stand up, or to look far away or to do any sort of little things that are not “staring on a screen”.

I am using it now for around 3 months and I am convinced that Stretchly helped me extinguish my back and neck aches and generally staying sound.

How to Take a Full-Sized Screenshot in Chrome

Sometimes you have to take screenshots not only of what is visible on the screen, but of all what would be visible on web page if you’d scroll all the way down.

In Chrome, you can create such a screenshot without an add-on. How?

  1. Click the main menu, the three points at the upper right.
  2. Select More tools and then Developer tools
  3. In the deveolper tools, select their three points at the upper right and then Run command.
  4. Type screensh and select Capture full size screenshot.
  5. The screenshot will be saved to your download folder.

The POWER Function in SQL is Crazy

T-SQL’s POWER function baffled me. It rounds its result to the number of decimals that have been given in its first argument. I have not found any other function or math operation in SQL which does this.

It is absolutely astonishing and just nonsense. You need to be aware of it to avoid very bad miscalculations. See this:

SELECT 0.5 * 0.5, POWER(0.5, 2), POWER(0.5, 2.0000)  
  -->  0.25           0.3             0.3

This is not just a display effect of MS SQL Server Management Studio. It really calculates with these rounded values. See and marvel.

SELECT (0.5 * 0.5) * 4, POWER(0.5, 2) * 4 
 --> 1.00   1.2

Look further and wonder.

SELECT 0.5/1000, 0.5*0.001,  POWER(0.10, 3), 0.5 * POWER(0.100, 3)
 -->   0.000500    0.0005            0.000          0.0005

SELECT 1.0/10000, 1.0*0.0001, POWER(0.10, 4), POWER(0.1000, 4)
 -->   0.0001000    0.00010     0.00            0.00001

C# String Formatting

Time and again I’m forgetting about C# string formatting syntax. The MS pages about it are bad.
But here is a page with a lot of number string formatting examples and at the bottom a little testing tool. Quite valuable.

Some examples I wanted to mention here:

| double d= |    a=     | d.ToString(a) | remark 
|-----------|-----------|---------------|--------
| 1234.57   | "0"       | 1235          | rounded  
| 1234.57   | "0.0"     | 1234.6        | rounded  
| 1234      | "0.0"     | 1234.0        | .0: show digit always 
| 1234.57   | "0.#"     | 1234.6        | .#: show digit only if needed 
| 1234.57   | "0.##"    | 1234.57       |
| 1234.57   | "0.###"   | 1234.57       |
| 1234      | "0.#"     | 1234          | 
| 1234.567  | "F1"      | 1234.6        | F: float with one decimal
| 1234.567  | "F"       | 1234.57       | F: float with two decimals 
| 1234.567  | "F3"      | 1234.567      | F: float with three decimals 
|    1.23   | "##.##"   | 1.23          | #.: show digit only if needed 
|    0.23   | "##.##"   | .23           |
|    0.23   | "#0.##"   | 0.23          |
|    0.23   | "00.##"   | 00.23         |
|    0.23   | ",5#0.##" |  0.23         | Probably does not work with 
|      d.ToString(a), but does work with string.Format or  
|      string interpolation.

| int d= |    a=        | d.ToString(a) | remark 
|--------|--------------|---------------|--------
|   12   | "0"          | 12            |   
|   12   | "00"         | 12            | 
|   12   | "000"        | 012           | 
|   12   | "+00;X00"    | +12           | first for > 0 
|   12   | "X"          | C             |  
|   12   | "x4"         | 000c          |
|   -12  | "+00;X00"    | X12           | second for < 0  
|   0    | "+00;X00"    | +0            | first for == 0
|   0    | "+00;X00;AQ" | AQ            | third for == 0, if existing

String interpolation $"{d}" can be formatted with all the same format markers like this: $"{d:0.##}".

Here is a page with a lot of DateTime string formatting examples and at the bottom a little testing tool. Quite valuable.

Some examples I wanted to mention here:

| DateTime d=         |    a=                  | d.ToString(a)  
|---------------------|------------------------|------------------
| 2020-05-19 13:47:27 | "yy-MM-dd HH:mm:ss"    | 20-05-19 13:47:27 
| 2020-05-19 13:47:27 | "yyyy-MM-dd HH:mm"     | 2020-05-19 13:47 
| 2020-05-19 13:47:27 | "yyyyMMddTHHmm"        | 20200519T1347 

| DateTime d=         | c = Culture.       | d.ToString(c)  
|                     | GetCultureInfo(..) |
|---------------------|--------------------|----------------------
| 2021-05-19 13:47:27 |        "DE"        | 19.05.2021 13:47:27
| 2021-05-19 13:47:27 |        "PL"        | 19.05.2021 13:47:27
| 2021-05-19 13:47:27 |        "RU"        | 19.05.2021 13:47:27
| 2021-05-19 13:47:27 |        "en-GB"     | 19/05/2021 13:47:27
| 2021-05-19 13:47:27 |        "en-US"     | 5/19/2021 1:47:27 PM