Friday, May 27, 2022

Code & Coffee - 5/27/2022

 Code & Coffee - 5/27/2022

  1. Ceiling fans and Z-Waves and Zigbees
  2. Internships
    1. What makes a good project
    2. Database change management
    3. One first project was a survey engine in MS Access
      1. Say what,  a shared access db on sharepoint?
    4. Birds in ceilings
    5. Hand coded sorting because didn't know about sql sort
  3. Big Query
    1. Partitions and clustering
    2. Querying for a specific field in 13 terabytes took under 2 seconds.
    3. PubSub and implementing CDC and pseudo transaction ish things.
  4. SSIS Upgrade woes
    1. And general database woes causing prod outages
    2. Lets let the new guy fiddle with prod data, sounds like a great idea.
  5. Miss Dig and cable and gas marking.
    1. Fire trucks and Gas trucks show up pretty fast
  6. SAP is going live
  7. Mental health days
    1. Preemptive mental health days may be even better than reactive days.
    2. Preserve instead of chase mental health
  8. Having fun with Cloujure
    1. What does #?@: <some variable name> mean???
    2. Context: [1 2 #?@(:clj [3 4] :cljs [5 6])]
    3. Its a vector with reader conditionals
    4. https://clojure.org/reference/reader#_reader_conditionals
    5. Immutability Changes Everything:
      1. https://queue.acm.org/detail.cfm?id=2884038
      2. http://www.cidrdb.org/cidr2015/Papers/CIDR15_Paper16.pdf
    6. REPLing is fun
      1. Kinda like changing a tire will the car is rolling except without the crashing bit (usually)
    7. qotw: "99% of the code is not sideffectful"
      1. just be careful of the rest
  9. Bitcoin whirlpools and chains and other stuff
      1. Sparrow, samurai, tors and mores
      2. ¯\_(ツ)_/¯

Friday, May 20, 2022

Code & Coffee - 4/29/2022

Code & Coffee - 4/29/2022

 Topic: "Git Tips & Tricks"


  • The first tip came even before we started:
    • "I won't be able to make it tomorrow but I'm sure Dave will bring up many of my favorites, but in case he doesn't, git worktree, git restore, patch mode, git add -N/--intent-to-add ........"
    • git worktree:
    • git restore:
    • Patch mode:
    • git add -N/--intent-to-add ......
      • Inform git that you will be adding a path in the future, this allows you to see the files in the directory when running git status and seeing diffs with git diff.
      • Docs: https://git-scm.com/docs/git-add#Documentation/git-add.txt--N
  • Squashing commits
    • it is part of git merge, dig up docs
  • Signing commits
    • why and how
  • git bisect
    • use case and how to use it
    • it has a mode where you can pass in a script and it will automatically find the issue
  • "Arlo's git notation"
    • find a link
    • commit message prefix indicates the nature of the commit
  • Git log
    • show only merges
  • Git garbage collection
    • what it is for and how it works
    • oops checked in node_modules again
    • oops that password shouldn't have been in there.
  • Pre-commit hooks/hooks in general
    • vulgarity checker.... or maybe just runs the tests and linter
  • Interactive add
    • see git add -N
    • -P will get straight to patch mode without the menu
    • many commands that change the index support patch mode 
  • git reset -tests
  • git diff
  • dave's rebase strategy... 
    • heard only part of it, was in the other meeting already
    • git rerere - setting to help with repeated rebase resolution

  • Commits from last night
    • Contains vulgarity, its kinda the point it harvests commits from last night that contain indications of frustration
    •  https://latenightcommits.com/



make notes about the ~ thing.

Code & Coffee 5/20/2022

 Code & Coffee 5/20/2022


The goal is to drive out good test naming in a group setting using "isLeapYear" as a sample problem.

  1. Work as a group to derive 


Topic: Having fun with isLeapYear

  1. Had a bit of fun with the exercise
    1. Noticed that people liked to try to optimize it
    2. Was mentioned that isLeapYear looks a lot like FizzBuzz
    3. replit is not as good as real vim.
  2. Talked a bunch about logging and interpolation penalties for unlogged messages (not logged because of logging level)
  3. Talked about interesting stuff in the hiring space.
  4. Talked about COBOL for a little bit.
  5. What is a Senior Developer?
    1. Capable of mentoring more than putting out code
    2. Interviewing skills
  6. Flex box 
    1. And overflow interact in an interesting way
    2. overflow hidden and visible are part of the weird interaction.
  7. REPL driven development
    1. Sooo good

The code we came up with:


/*

Every year that is exactly divisible by four is a leap year,

except for years that are exactly divisible by 100,

but these centurial years are leap years if they are exactly divisible by 400. 

For example, 

the years 1700, 1800, and 1900 are not leap years,

but the years 1600 and 2000 are.[14]

*/


//logger.warn("Something {}").mdc("one", () -> "two").log();


function isLeapYear(year) {

  return (year & 3) == 0 && (

    (year % 25) != 0 || (year & 15) == 0

  );

}


function isLeapYearDate(year) {

  return new Date(year, 1, 29).getDate() === 29;

}


function isLeapYearBad(year) {

  const modYear = year % 400;


  if(year === 0) return true;

  if(year % 100 === 0) return false;

  return false;

}

function isLeapYear3(year) {

  if (year % 4 == 0) {

    if (year % 100 == 0) {

      if (year % 400 == 0) {

        return true

      }

      return false;

    }

    return true;

  }

  return false;

}


function oldIsLeapYear(year) {

  if (year % 400 == 0) {

    return true;

  } else if (year % 100 == 0) {

    return false;

  } else if (year % 4 == 0) {

    return true;

  }

  return false;

}




group('leap year tests', () => {

  ok('0 is not a leap year', !isLeapYear(0));

  ok('negative numbers dont blow up', !isLeapYear(-1));

  

  group('Year not divisible by 4', () => {

    ok('1601 is not a leap year', !isLeapYear(1601));

  });

  

  group('Years divisible by 400', () => {

    ok('1600 is a leap year', isLeapYear(1600));

    ok('2000 is a leap year', isLeapYear(2000));

  });

  

  group('Years divisible by 100', () => {

    ok('1700 is not a leap year', !isLeapYear(1700));

    ok('1800 is not a leap year', !isLeapYear(1800));

    ok('1900 is not a leap year', !isLeapYear(1800));

  });

});


// This is another potential style:

group('A year is a leap year', () => {

  ok('if it is divisible by 4 but not 100 (2020)', isLeapYear(2020));

  ok('if it is divisible by 4 but not 100 (1984)', isLeapYear(1984));

  ok('if it is divisible by 4 but not 100 (4)', isLeapYear(4));


  ok('if it is divisible by 400 (400)', isLeapYear(400));

  ok('if it is divisible by 400 (2400)', isLeapYear(2400));

});


group('A year is not a leap year', () => {

  ok('if it is not divisible by 4 (2018)', !isLeapYear(2018));

  ok('if it is not divisible by 4 (2017)', !isLeapYear(2017));


  ok('if it is not divisible by 100 but not by 400 (2100)', !isLeapYear(2100));

});



// test "framework", just enough of one to play with anyway.

function ok(message, result) {

  const GREEN = 32;

  const RED = 31;

  if (result) {

    log(`OK - ${message}`, GREEN);

    return;

  }

  log(`FAIL - ${message}`, RED);

}


function group(description, fn) {

  log(description);

  indentMore();

  fn();

  indentLess();

}


function indenter() {

  if (typeof indenter.indent !== 'undefined' && Number.isInteger(indenter.indent)) 

    return ' '.repeat(indenter.indent);

  return '';

}

function indentMore() {

  if (typeof indenter.indent === 'undefined' || !Number.isInteger(indenter.indent)) 

    indenter.indent = 0;

  indenter.indent += 2;

}

function indentLess() {

  if (typeof indenter.indent === 'undefined' || !Number.isInteger(indenter.indent))

    indenter.indent = 0;

  indenter.indent -= 2;

  indenter.indent = Math.max(0, indenter.indent);

}


function log(message, color) {

  const prefix = indenter() + (color ? `\x1b[${color}m` : '');

  const suffix = color ? '\033[0m' : '';

  console.log(prefix + message + suffix);

}




Resources:

  1. Hoare Triple
    1. Preconditions and postconditions defining a program.
    2. https://wiki.c2.com/?HoareTriple
    3. https://softwarefoundations.cis.upenn.edu/plf-current/Hoare.html
    4. Tony himself expounding upon it:
      1. https://www.youtube.com/watch?v=czzp8gMESSY
    5. Hoar's paper:
      1. https://dl.acm.org/doi/pdf/10.1145/363235.363259
      2. the less exciting page pointing to it: https://dl.acm.org/doi/10.1145/363235.363259
  2. Kevlin Henney presenting on GUTs
    1. https://www.youtube.com/watch?v=tWn8RA_DEic
    2. https://www.youtube.com/watch?v=azoucC_fwzw
    3. https://www.theregister.com/2007/07/28/what_are_your_units/