Millennial Code - Real Production Code

This is how I'd expect a modern millennial to code (you know - the kind of person who considers facts to be particular opinions).

private bool CheckExist(out int id, out bool manageAll, out string orgCode)
        bool Yes = false; 
        id = -1;
        foreach (DataRow r in dv.Table.Rows)
            if (r.ItemArray[1].ToString() == TextBoxUsername.Text && 
                r.ItemArray[2].ToString() == TextBoxPassword.Text)
                Yes = true;
                id = (int) r.ItemArray[0];

    return Yes;

Because Everything Has To Be Equal

So, so stupid. We now have a pregnant man emoticon. I get the inclusivity thing, but if we want to have equal representation for every possible combination of anything that can happen or can be imagined, then we will run out of resources.

Pregnant Man - because, well we do get pregnant!
Pregnant Man - because, well we do get pregnant!

How to Upgrade HDD in UCK-G2-PLUS

If you have a Unifi CloudKey Gen2+ controller with existing video footage and want to preserve that as well as any configuration settings that might be stored there, but upgrade the capacity of the default HDD from 1TB to something more usable, this article is for you.

  1. Get a larger 2.5" HDD, I used the internal drive from this external USB drive. It is by far the cheapest option I could find to get a 5TB drive.
  2. Turn off the CloudKey
  3. Remove the 1TB drive (source) from the CloudKey and connect it to a PC.
  4. Connect the new 5TB (target) drive to a PC
  5. Issue the following command from MacOS / Linux:
    dd if=/dev/diskA of=/dev/diskB bs=1m
    (Make sure A is the SOURCE and B is the TARGET, on macOS use diskutil list to find the right drive)
  6. Once the copy is done (mine took 2 hours or so) run GParted - you can boot it from a Live ISO.
  7. Accept the recommendation to extend the partition to fill the disk
  8. Edit the large partition by moving the partition slider to the right to occupy all space and apply
  9. This resize might take 10 - 20 minutes
  10. Once done eject both disks.
  11. Gently pry open the red top from the black base using a small spatula.
  12. Remove the HDD
  13. Remove the metal shroud and small USB to SATA adapter.
  14. Pop out the 1TB from the carriage from the CloudKey and snap in the new one
  15. Boot up the CloudKey and give the OS about 10 - 20 minutes to recognize the extra space. Everything should be preserved.

Modern Pitfall in Code Performance

Code syntax has become increasingly complex and expressive in recent years. There used to be a time when procedural languages like Java, C, C++, C# were purely procedural and functional languages like Lisp, Erlang were purely (mostly) declarative. Since these are very different mechanisms of programming, when writing code in a specific language a programmer tends to think either declaratively or imperatively.

So consider this simple example problem: An object needs to be created with a list of entries that contain properties describing a specific year and week. Let's say that property is: Hours. So each year / week combination has one property defined called Hours. This object gets instantiated and passed the list of resolved items. It also has a bunch of properties to allow iteration over the years and weeks to build up a grid of Hours and totals. A very naive implementation might look something like this in C#:

class SomeHolder {
  private Dictionary<int, Dictionary<int, List<int>>> entities;

  public List<int> Years { 
    List<int> years = new List<int>();
    get { 
      for (int year in entities.Keys) 
      return years;

  public Dictionary<int, List<int>> Weeks { 
    get { 
      Dictionary<int, List<int>> weeks = new Dictionary<int, List<int>>();
      for (int year in Years) {
        if (!weeks.ContainsKey(year))
          weeks[year] = new List<int>();
        for (int week in entities[year].Keys) 
      return weeks;

  public Dictionary<int, Dictionary<int, int>> WeekTotals {
    get {
      Dictionary<int, Dictionary<int, int>> totals = new Dictionary<int, Dictionary<int, int>>();

      for (int year in Years) {
        if (!totals.ContainsKey(year))
          totals[year] = new Dictionary<int, int>();
        for (int week in Weeks) {
          if (!totals[year].ContainsKey(week))
            totals[year][week] = 0;
          for (int hour in entities[year][week].Values) 
            totals[year][week] += hour;

      return totals;

  public SomeHolder(Dictionary<int, Dictionary<int, List<int>>> entities) {
    this.entities = entities;
Full Article


1Gbps Internet
1Gbps Internet