Red Mill, Clinton

Sony ILCE-7RM2 • FE 24-70mm F2.8 GM
ƒ/8 • 24mm • 1/100s • ISO 100

It’s a good practice to go through years’ old photos now and then, review the collection again with the current mindset, and post-process a photo or two from the pile. As experience expands with the time and number of clicks, the definition of a killer photo also evolves. You will be surprised to see an entirely different photo rendered every time compared to what you had in your mind when you pressed the shutter release button.

Why the Pomodoro Technique Is Failing You

Tonya Dalton:

While the theory behind the Pomodoro Technique is solid – giving yourself focused, intentional blocks of time to dive into important work is extremely powerful – the problem is that the times are way too short. Research proves it takes an average of 23 minutes to get into our deep work zone where we are doing our best work. With the Pomodoro Technique, you interrupt yourself with a break just as you’re getting into that deep work zone.

cheat.sh - community driven cheat sheets

Want to access community-driven repositories of cheat sheets with the shell command? cheat.sh is the tool you are looking for. Fire up your terminal, and run curl cht.sh to start exploring cheat sheets maintain by various development communities. The command will provide a concise and comprehensive response to your queries instead of dumping multiple search results at you.

cheat.sh - Cmder

cheat.sh usage is pretty straight forward. Follow the query format:

$ curl cht.sh/{language}/{your query}

For example, if you want to refer cheat sheet of posting a JSON request in Go, command to query the cht.sh will be:

$ curl cht.sh/go/post-json
cheat.sh - Go Post Json

And similarly, for C#, command will be:

$ curl cht.sh/csharp/post-json
cheat.sh - C# Post Json

Show / Hide hidden items in File Explorer with a single shortcut Key

There is, unfortunately, no shortcut key available to toggle between showing and hiding files or folder in the File Explorer. Hence this AutoHotKey script. You can toggle the view in File Explorer to show or hide with the just a Win+h shortcut key.

This script is not that fancy, it just toggles between two different values of the specific registry key and will send F5 keystroke to refresh the view in File Explorer.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
SetTitleMatchMode, 2
#IfWinActive ahk_class CabinetWClass
#h::
  RegRead, HiddenRegValue, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden

  if HiddenRegValue = 2 
    RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 1
  Else
    RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 2

  WinGetClass, CabinetWClass
  Send {F5}
  return
#If

If you don’t prefer the above script, you can still toggle hidden items with the combination of multiple keystrokes in File Explorer. The key combination is Alt+v hh.

Customize object displays in the Visual Studio debugger YOUR way

Leslie Richardson on not so commonly used attribute DebuggerDisplay:

By writing DebuggerDisplay syntax at the top of a class, you can choose what strings and properties you want at the top of each object node in debugger windows. Besides displaying strings in debugger windows, adding curly brackets ({}) to the DebuggerDisplay attribute allows Visual Studio to display the value of a property or method that you specify.

I attempt to create a small console application below to follow the usage of DebuggerDisplay.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace ConsoleApp
{
  [DebuggerDisplay("{LastName}, {FirstName}")]
  public class Worker
  {
      public int Id { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
      public string Address { get; set; }
      public string City { get; set; }
      public string State { get; set; }
      public string Zip { get; set; }
      public string Phone { get; set; }
  }

  class Program
  {
      static void Main(string[] args)
      {
          List<Worker> workers = new List<Worker>();

          List<Worker> workers = new List<Worker>();
          workers.Add(
              new Worker {
                  FirstName = "Michael",
                  LastName = "Springer",
                  City = "Atlanta",
                  Phone = "001-232-1233"
              });
          workers.Add(
              new Worker {
                  FirstName = "Lloyd",
                  LastName = "Bever",
                  City = "Fort Myers",
                  Phone = ""
              });
          workers.Add(
              new Worker {
                  FirstName = "Vincent",
                  LastName = "Covey",
                  City = "Chester Heights",
                  Phone = "888-232-1233"
              });

          Console.WriteLine(workers.Count);
          Console.ReadKey();
      }
  }
}
QuickWatch - Without DebuggerDisplay
QuickWatch - With DebuggerDisplay

You can also use nq (no quote) specifier if you don’t prefer to see quotes in debug values.

1
2
3
4
5
6
  [DebuggerDisplay("{LastName, nq}, {FirstName, nq}")]
  public class Worker
  {
    //...
  }
}
QuickWatch - DebuggerDisplay with No Quote Specifier

You can further extend DebuggerDisplay if you want to include an expression in debug values. Just add a private method or property in the target class, and provide that method or property to DebuggerDisplay.

1
2
3
4
5
6
7
8
9
[DebuggerDisplay("{DebuggerString(), nq}")]
public class Worker
{
  private string DebuggerString()
  {
      return string.Format($"{FirstName}, {LastName}. Has Phone: {!Phone.Equals(string.Empty)}");
  }
  //...
}
QuickWatch - DebuggerDisplay using Expression

A visual guide to Go Memory Allocator from scratch (Golang)

Ankur Anand has written an in-depth blog post to explain how memory management work in Go.

… the general idea of the Go memory management is to allocate memory using different memory structures using different cache level memory for objects of different sizes. Splitting a single block of consecutive addresses received from the operating system, into a multi-level cache improve the efficiency of memory allocation by reducing the locks and then allocating memory allocations according to the specified size reduces memory fragmentation and facilitates faster GC after the memory is released.

Otter Cliffs - Sunrise

Sony ILCE-7RM2 • FE 24-70mm F2.8 GM
ƒ/2.8 • 24.0mm • 1/6400s • ISO 800

This photo is my failed attempt to capture water splash using high shutter speed. Taking a splash water photography always requires a lot of trial and error as you need to sync your shutter click with the exact moment of the splash. The great thing about the digital camera is that you can take thousands of photos at the location and later review and delete all of them except your star photo.

Paste rich text as clean text

This little AutoHotKey snippet will make copying rich text and pasting as clean text a bit less hassle:

1
2
3
4
5
^+v::
  clipboard := ClipboardAll ;Copy clipboard contents to a variable
  Clipboard = %clipboard% ;Save content of the variable back to the clipboard
  Send ^v ;Send Ctrl+V command
  return

The assigned shortcut key is Ctrl+Shift+V, which you can change per your preference. Copy any rich text from a web site, open word document or new email in Outlook and press Ctrl+Shift+V. AutoHotKey snippet will remove all style formattings and will paste just the clean text.

Should array length be stored into a local variable in C#?

Is there any impact in execution performance because of using array.Length directly as for exit condition? Which one of following methods will excute faster?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
public int WithoutVariable() {
    int sum = 0;
    for (int i = 0; i < array.Length; i++) {
        sum += array[i];
    }
    return sum;
}

public int WithVariable() {
    int sum = 0;
    int length = array.Length;
    for (int i = 0; i < length; i++) {
        sum += array[i];
    }
    return sum;
}

Dmitry Yudakov concludes through digging into the IL code generated by JIT compiler for both methods:

… both methods will compile into the exact same code, but the first one is written faster, even though there isn’t any benefit in terms of execution time.

Serializing a PascalCase Newtonsoft.Json JObject to camelCase

Andrew Lock on some of the quirks of using JObject, in particular the way it doesn’t honour the contract resolver settings used to serialize a given object graph, and three different ways to work around the behavior: set the global serializations settings, store the JObject using camelCase property names, or convert from a PascalCase JObject to a camelCase JObject. For the final option, a provided an extension method and unit tests to demonstrate the behavior.

Dr. Alan Kay on the Meaning of “Object-Oriented Programming”

In this email exchange, Alan Kay, the person who invented the term Object-Oriented, outlined the original intent behind the term Object:

OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I’m not aware of them.

Hadlock Falls, Acadia

Sony ILCE-7RM3 • FE 16-35mm F2.8 GM
ƒ/5.6 • 35mm • 0.5s • ISO 100

Keeping exposure timing less than a half second has another benefit other than tack sharp leaves and branches. If someone inadvertently walks into your long exposure waterfall framing, you take that opportunity and include that person into your photo with less probability of that person will blur out.

I was so happy to take this shot. The person in the photo counterbalances the waterfall in the overall structure of the composition. This balance shifts the attention away from the waterfall as the main subject adds another dimension to the composition, which will be otherwise a predictable and bland photo.

CSS Grid Generator

This online tool generates a basic CSS Grid code to make dynamic layouts.

CSS Grid Generator

Provide your grid configuration and hit Please may I have some code button and voila! You will have your CSS style ready to be copied.

.parent {
  display: grid;

  grid-template-columns: 50px 1fr 3fr 1fr 50px;

  grid-template-rows: 75px 1fr 75px;

  grid-column-gap: 0px;

  grid-row-gap: 0px;

  .div1 { grid-area: 1 / 1 / 2 / 6; }
  .div2 { grid-area: 2 / 1 / 3 / 2; }
  .div3 { grid-area: 2 / 2 / 3 / 3; }
  .div4 { grid-area: 2 / 3 / 3 / 4; }
  .div5 { grid-area: 3 / 2 / 4 / 5; }
  .div6 { grid-area: 3 / 5 / 4 / 6; }
}