Text

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Thursday, October 24, 2019

Visual Studio Remote Debugging 2019

There is more than one way to do this.  Here is a summary of what has worked best for me.

One time SERVER MACHINE setup:

The remote debugger needs to be installed

They are constantly changing where to find it, but here is where to find it today:


One time DEVELOPER MACHINE setup

Visual Studio settings

Under tools / options then debugging / symbols:

  • If the debug mode PDB files for your projects are set up to be placed to a central symbols location then make sure that location is represented in the "symbol files locations" area.
  • For manageable performance:  Check "Load only symbols for specified components" but do not actually specify any in the "specify include modules" window.  This will only load the symbols for the components you have built and placed symbol files next to.  Otherwise it can take a VERY long time to load up symbols when starting to debug.

One time EACH PROJECT settings change


  • Do these changes under debug mode only.
  • If a project is usually maintained by engineers who debug it on their own machines then consider not checking in these project settings changes into source control.
  • If your debugging symbols PDB files get places in many different locations specific to each project, then do the steps in the previous "One time DEVELOPER MACHINE setup" section, for the project in question.
  • The working directory must be set to a location that has the target components on both the local and remote machines.  Research item:  This might only be true for unmanaged C++.
  • Within your solution, make sure the project you want to debug is set up as the "startup project", just like when debugging locally.  It will give a confusing error message if you have the wrong project set for startup.
  • The rest of the considerations are different for unmanaged C++ or managed C#.NET projects.

Unmanaged C++

  • For debug mode unmanaged C++:  Link with static libraries instead of the DLL versions.  This avoids the need to install debug mode runtime libraries on the server.  You may need to undefine _AFXDLL.  It is unlikely your component is truly an "AFX Extension".

Under properties / configuration / debug


  • Fill in the remote debugging fields to point to the server and port displayed by the remote debugger.
  • I’ve had the most luck with attach set to NO, but this is because I often work on processes that run multiple instances of the same component from different processes, in which case the debugger tries to attach to ever single one of them.  Unhelpful and takes a VERY long time.
  • Make sure the copy of the executable you want to run is not already running on the server.
  • Let the remote debugger launch your executable.

Managed C#.NET

Under properties / debug


  • Check the Use Remote Machine box and fill in the machine name and port as seen in the remote debugger window on the server.  E.g. servername:4024
  • Set whichever command line arguments necessary.

One time GETTING READY FOR DEBUGGING steps


  • Launch remote debugger
    • Search "Remote Debugger" on the server.
    • Make note of the machine name and port it displays.
  • Set breakpoints
  • Be ready to to copy components to the remote machine
    • Be this post-build steps, an XCOPY script, or manually copying with file explorer.  But you could be doing this over and over, so plan accordingly.
    • C++
      • Copy component plus the PDB file from the same build.
    • C#
      • Make sure all dependencies are present on the remote machine.  Assemblies, config files, etc.
      • Copy component.  No need to copy the PDB file, it can successfully use the local one.

DEBUGGING steps

Place code to be debugged on remote machine


  • Build in debug mode
  • Copy components to remote machine

Start debugging

It will work like usual except:

  • Choose the Remote Windows Debugger
  • Some parts will take longer, especially loading symbols.





Friday, September 13, 2019

Play it straight

It's sometimes hard to satisfy a sense of humor when programming.  But remember that the joke wears thin after a while, so it is almost never worth including a joke within production code.  It's hard to tell what circumstances it will come up in later, or with whom it will come up.

I once had a manager encourage me to slightly rename a component named with an acronym.  It was to become the "File Update Control Module".  I called it something else.  Which made it easier to not add insult to injury later during customer support issues.

Another time, I had a program that had some functionality that included doing two complicated calculations that culminated in comparing the two results with each other.  Although I named the functions well to self-document what each calculation result was, I still called the two final variables "apples" and "oranges".  It was apparently a slow day, so I amused myself by having it then compare apples to oranges at the end.  The code reviewer was amused as well, but their advice to name the variables more appropriately was good.  The joke wears thin, and any amusement is more than offset by even a little extra cognitive load on anyone else years later trying to determine what that code was doing.

One co-worker liked setting flag variables to a value of -666.  He would name a constant "HellFreezesOver" just so he could have code containing "do...until" loops that included "until (HellFreezesOver)."  One time that value bled out into an error message reporting error code -666.  A customer already impacted by the error expressed not being amused by the error code.  Will a customer to feel an issue is being taken seriously if the error message itself appears to include a joke?

Monday, August 19, 2019

Numpy array multiplication


Dot product

  • Applies to one dimensional arrays, aka vectors.
  • The sum of the products of the components of the vectors.
  • The result supposedly represents “how similar the two vectors are”.
  • The first elements of each vector multiplied, then the second, third, etc.  Then add them all together.
  • Aka inner product
  • Aka scalar product.  Since the result is a scalar.
  • Notation is the two vector names next to each other with a superscripted T above the first.
  • In Numpy, the dot method of the first vector is called, passing the second vector as an argument. 

Hadamard product

  • Can do this on vectors of the same size.
  • Result is a vector also that same size.
  • The first elements of each vector multiplied and become the first element of the answer. Repeat for all elements.
  • Notation is a very small centered circle between the elements.
  • In Numpy, the * operator is used.

Matrix multiplication

  • Applies to arrays with dimensions higher than one.  
    • Technically when there is only one dimension in either or both arrays, it is the same process described here, but each row and/or column have only one element, so it can be simpler to think of it only in terms of the "Dot Product" description above.
  • In Numpy, a matrix will be an array of arrays
  • Can multiply two matrices A and B if the number of [rows, columns] in matrix A is equal to the number of [columns, rows].
  • Result is another matrix with the width of B and the height of A.
  • Each element of the result is a scalar.
  • Each element of the result is the dot product of corresponding rows of A with columns of B.
  • The first row of the result is the dot product of the first row of A with each of the columns of B.
  • The second row of the result is the dot product of the second row of A with each of the columns of B.
  • And so on.
  • Notation is the names of the two matrices next to each other.
  • In Numpy, the dot method of the first array is called, passing the second array as an argument.


Friday, August 16, 2019

Recommended process for process document distribution

Picture a "process" document that describes how a group of people will need to do some part of their ongoing work from that point forward.  At some point that group needs to become aware of it.  Such times include:
  • When it is first created.
  • When it is updated.
  • Introducing a new hire to it.

Should you send them the document?

No.  It's not the end of the world if you do, but, there is a better way.

Why not send the document?

Basically it wastes little slices of time multiplied by the number of recipients.
  • Everyone who receives it is now responsible for curating their own private copy every time a new revision is sent out.  This wasted time is multiplied every time another update is sent.
  • The document is just a snapshot of the actual document and will be out of date the moment any other modification is made.  There will always be doubt about whether any given copy is the most recent update, and possibly time wasted making sure.
  • New hires will need to obtain a copy.  Usually after confusion caused by not knowing that the document exists.  Usually wasting their time searching and the time of other people as they are forced to ask around about it.
  • Sending a copy of the document attached to a mass e-mail also wastes space in the e-mail system.
So then how to provide the document to the group?

Recommended Process

Get ready

Establish an official location for the document if one does not already exist.  If an effective broader official location for such documents does not exist, that is a larger problem to be solved separately, but if that is the case, don't let it stop you.  Work around the problem for now.  Pioneer a location.  Be a voice for positive ongoing improvement.  If this step is done properly, it will only need to be done the very first time.

Get set

Store the document there.  This shouldn't take much time.  Presumably you've saved the document "somewhere" before you want to send it, right?

Go

When attention is needed, send people of a LINK to the document along with any introduction or comments about what was just changed.

This process works even better if

  • The "official location" of the document is within a broader "official location" for all similar documents, and that location is in the form of something that the audience can be subscribed to receive notifications when something is updated.
  • New hires are given the location of the broader "official location", so they automatically have any new documents as they are added.

Monday, August 12, 2019

How to resolve linker error LNK2005

The C runtime libraries define the DllMain function used in all DLL components.  But MFC enabled DLL component projects also have an MFC specific version of this function that gets bound in by default.  So what happens when a project binds with both the DLL versions of the C runtime and the MFC libraries?  Since each of those has their own version of DllMain already defined, there can be a conflict.


LNK2005 _DllMain@12 already defined in MSVCRT.lib(dllmain.obj) mfcs100.lib(dllmodul.obj)

So how can this ever NOT be a problem?  Well, the C runtime DLL is smart enough to use trickerly to protect itself from there already being a DllMain defined at compile time.  This is good, as otherwise none of our "user" DLL components that define their own version of this function could ever bind with the C runtime.

This linker error can still be a problem though, because the MFC libraries do NOT protect themselves from the possibility that this function already exists.  They must think that anyone only ever wrote "pure" MFC components that would never include any other libraries or ever define such functions ourselves.

So to resolve this is a matter of making sure that the MFC libraries are bound first.  How can we do this?


  1. Remove the conflicting libraries from being included by searching the linker search paths in the default manner.
  2. Add the libraries explicitly in a specific order.
In the case of the specific error above, this resolution ends up looking like this:



The two libraries are ignored from among the "default" libraries.  Then they are added as "additional" dependencies instead.  Note that the MFC library is placed first in the Additional Dependencies, followed by the C runtime.  This must be done separately for release mode and debug mode configurations as the libraries are named slightly differently for each mode.

Saturday, August 10, 2019

Deep Learning Professional Certificate Program (edX)


Formal education makes a living, but self-education makes a fortune,” - Jim Rohn

Professional Certificate in Deep Learning

https://www.edx.org/professional-certificate/ibm-deep-learning

Due to the heavy use of Data Science when working on Deep Learning, I've decided take an entirely different certification course first...
    ·         oDeep Learning Fundamentals with Keras
o   Prerequisites:
§  Python Programming.
·        See prerequisites of next section for more Python related courses
·         https://www.edx.org/course/python-basics-for-data-science-2 Ã¾
§  Machine Learning with Python. 
§  Partial Derivatives. edX recommended Khan Academy.  I also traded a sushi dinner to my son for some tutoring, where I posted my notes here and here.
·         https://www.youtube.com/watch?v=AXqhWeUEtQU Introduction Ã¾
·         https://www.youtube.com/watch?v=kdMep5GUOBw Formal definition Ã¾
·         https://www.youtube.com/watch?v=dfvnCHqzK54 And Graphs Ã¾

·         oDeep Learning with Python and PyTorch
o   Prerequisites.  Here I elect to use Pluralsight courses I deemed similar to the edX courses.
§  Python & Jupyter notebooks
·         Python
·         Jupyter notebook
§  Machine Learning concepts
§  Deep Learning concepts

·         oDeep Learning with Tensorflow  
o   Prerequisites:
§  Same prerequisites as previous course.

·        oUsing GPUs to Scale and Speed-up Deep Learning  
o   Prerequisites:
§  No prerequisites.

·         oApplied Deep Learning Capstone Project  
o   Prerequisites:
§  Completed all courses in the Deep Learning Professional Certification Program  o


Partial Derivatives


Although this applies to higher dimensions too, this example sticks with a three variable equation because it can be visualized in three dimensional space.  It will look like a sheet that is tilted and/or bent in various ways.

Example equation



Graphed at geogebra



Partial derivative

This is essentially picking a point along one of the planes to get the equation for the line that is formed out of the sheet right there with respect to the other two planes.

Process

Starting with the original equation graphed above 

Pick a point along the Y axis.  In the graph above, the “sheet” crosses the Y axis at position 0, so using that it gives us this equation for the line that forms where the sheet passes that axis.





This is the slope along the z and x axes, it can be helpful to express it as 2/1.  If the image is turned to view edgewise along the sheet with respect to the z and x axes, this slope becomes observable:






























Derivatives

A two variable equation can be graphed on a simple two dimensional grid.  It will often be some sort of curved line.  The derivative is an equation that gives the slope of that line at a given point.

Example Equation


Can also be expressed as

Derivative


How was it derived?

The following power rule is applied to each term:


The way I think of it is that the “t” in the power rule is the entire term, which is usually a constant, a variable, and an exponent.

First term

The first term of the example equation is


Which when thought of as the “t” in the power rule with constant, variable, and exponent looks like this:



Applying the power rule means taking the exponent as the value “n”.  In this case 4.  Multiplying it by the front of the term is (4 x 1) or 4.  Changing the exponent to n-1 is (4-1) or 3.  So the first term derives to:


Second Term

Looking at the second term of the example equation and what it derives into shows the 3 being multiplied by the 2 and the exponent decreasing to 2.

Third Term

The third term is similar and becomes 8x.  The exponent was reduced to 1 so it need not be displayed anymore.

Fourth Term

The fourth term sees the exponent reducing down to zero, and since anything to the zeroth power is one, the x to the zeroth power becomes 1 and doesn’t need to be displayed anymore.  It just multiplies by the 5 and becomes the value 5.

Fifth Term

The fifth term is just a constant so like all constants, it derives to zero, so is effectively just dropped.  Why?  Because to get it into the “t” form for the power rule, it becomes:


With the starting exponent of zero, that means “n” is zero, and since the whole thing is going to be multiplied by “n” on the front, the whole term solves to zero.

Wednesday, August 7, 2019

Intentional Error

Sometimes it is difficult to test error handling.  Exceptions in different layers of the coding.  If an exception happens you want it to be logged, displayed, or otherwise findable.  If the exception handling doesn't properly make the exception details findable by the support analyst, they will have a tough time positively diagnosing the cause.

Yet to test the exception handling in every layer, one might need to sabotage various things.  Remove a file.  Lock down the permissions.  Temporarily remove an assembly.

Depending on the environment the test is conducted on, the ability to sabotage elements on the server may be difficult or impractical.  Especially for a QA tester that may not have access to the box, or the training to "correctly sabotage" elements on it.

One approach is to pick one of the free form fields of a data record, and establish a series of testing values.  Something easy enough to remember, but not prone to be added to real records.  Like the key words "Intentional Error" followed by a six digit number.

Different sections of the code that process that record can check the field for the key words and a unique number related to that code section.  If the key words and number are detected, the code immediately throws a defined "IntentionalErrorException".  The testing scripts include the key words and numbers to use, where the exception is to be reported, and key elements that must be included for the error to be useful to support analysts.



Tuesday, June 25, 2019

Working From Home

Advantages


Custom tailored schedule. Eat, nap, take breaks, focus on work, when and how it works best for you. You'll probably need to "keep an eye on e-mail", have your phone handy, and "stay close" during "business hours", but otherwise you are more free to tailor your schedule to be when you are most productive.

All the comforts of home. Cook your lunch at home in your own kitchen, with all your supplies and cookware available. Forget to apply deodorant that morning? Weather change so you are now dressed too warmly? Everything you need to address any eventuality is right here.

Flexibility. Sunny day? Mow the lawn now, work later when it's dark or raining. No need to have dentist appointments only with that person on the far side of town who is open until midnight.

Control of work space. The room where you do your work. The number and type of computer screens. The type of desk, chair, decor, lighting. Items that help you take breaks or think deeply. It can all be according to your preferences to set the conditions that work best specifically for you to be productive. You won't be forced to work in an open floor plan just because your company CEO somehow decided that was best for everyone.

Disadvantages


Interruptions. While you might think co-workers talking around you might interrupt you more, there are actually more interruptions at home.

Even if you live alone: If the delivery guy arrives, you'll be tempted to go retrieve the package right away. If you notice your floor is getting dusty, you might think that's a good time to sweep it. If your plumbing malfunctions, you'll need to fix it yourself right away.

But of course even more if you live with others: You plan when you want to "work on work" and when you want to "be home from work", but physically you are at home. Your family members and roommates know this, so not only do you need the discipline to stick to your your own plan, but they do too. And you can only control yourself.

Lack of structure. Whatever structure you need, you have to expend effort to make it happen. When you work away at an office, those managing that office impose schedules and other work related things on you. You don't have to worry about figuring those out; they just happen. But even outside the office, you get a transitional period during the commute to get yourself awake and mentally prepared before beginning work. On the way home, you'll also have some time to wind down and transition to a better mental state for home without any special effort or discipline. It just happens as a side effect of your commute. It's a balancing act to artificially impose these types of structure enough to transition well without starting to degrade the "flexibility" advantage.

Communication. Although technology is always improving this area, the people at the office are focused on what is around them. If you are never there but as a voice on the phone, it's harder for people to connect with you. If you are in a highly collaborative or deliberative industry, you will need to be present there in person so everyone is able to think of you as a real person and not just that annoying voice on the phone that is always reminding everyone to grab a mic or repeat the question. You need to connect before you can be a strong voice in a conversation or be able to successfully argue a point in a discussion. People need to know you before they will take you seriously. At one job I was the only remote attendee that used a webcam. In the main conference room I appeared by default on an 8 foot screen behind the main presenter. Better to be a joke than to be invisible. Just remember to meet the dress code, from the waist up, so nobody there gets flexibility envy.

Neglect. You really need to aggressively stay on top of things and form relationships with many people at the office, or you will be out of touch with things going on there. So much is communicated by word of mouth by people in the office that you won't hear unless you are asking about what's been happening. If you do not do this, you'll eventually find that the reason your work software doesn't work anymore is because everyone in the office is two versions ahead of you.

See the special section for remote jobs in my Links post.

Links

Technical

Decomposing Systems into modules - https://prl.ccs.neu.edu/img/p-tr-1971.pdf
https://www.fixtrading.org

Data Science / Machine Learning

https://www.anaconda.com/download - Data Science distribution (Python, Jupyter Notebook, over a thousand more packages)
https://www.anaconda.com/pycharm - PyCharm for Anaconda.
https://www.numpy.org
https://notebooks.azure.com - Jupyter Notebook as a service.
flask.pocoo.org - Flask.  Web Framework.
https://pypi.python.org/pypi - Python Package Index
www.jrsoftware.org/isinfo.php - Inno Setup.  Free installer for windows programs.

Career

Key Values — https://www.keyvalues.com/
https://www.monster.com/career-advice/article/going-back-to-work
https://www.thebalancecareers.com/job-search-4161939

Resumes

https://www.resumehelp.com/
https://www.livecareer.com/
https://resumegenius.com/

Job Boards

Indeed — https://www.indeed.com
Career Builders — https://www.careerbuilder.com/
LinkedIn — https://www.linkedin.com
Monster — https://www.monster.com
Simply Hired — https://www.simplyhired.com
Dice — https://www.dice.com

Remote Jobs

https://www.indeed.com/q-Remote-Work-From-Home-jobs.html
https://www.glassdoor.com/blog/companies-that-let-you-work-remotely/
https://www.skipthedrive.com/
virtualvocations.com

Me


JeffBohn.com


Computer Security Checklist


Clean

  • Remove unused apps and software programs.
    • In case any are providing an attack surface, as well as to save space and speed up scans.
  • Disk Cleanup.
    • Remove all but the most recent system restore point.

Keep software up to date

Automate as many of these as practical.  Subscribe to news feeds from vendors for any elements that cannot be automated.

  • Computer firmware.
  • Windows Update.
  • Virtual Private Network (VPN).
  • Antivirus.
  • Google Chrome / Help / About.
  • Other browsers.
  • Other software (Visual Studio, etc.)
  • Router firmware.
  • Phone.

Run Anti-Malware

  • Windows Defender.
  • Malwarebytes.com
  • Google Chrome / settings / advanced / reset and cleanup / clean up computer / Find harmful software.

Passwords

  • Change them regularly to make the window of time it takes to crack them smaller.
  • A minimum of 10 characters, the longer the better.  Make brute force attacks take as long as possible.
  • Use letters, numbers, symbols. Faster focus brute force attacks that do not use all of these won't impact you.  Only be susceptible to the ones that will take longer.

Back up and Encrypt sensitive files

  • In case something gets in, it can't use it to damage you or hold it for ransom.

Links