At A Glance Main Projects Tutorials Resume

Messenger


There currently is no messenger. Manually, you can contact me via:

Google Talk: palen1c at gmail.com

Twitter: @Technogumbo



Debugging Tip For Node on AWS Lambda Edge

Mon, 13 Aug 2019 11:54:52 EST

Lambda is hands down my favorite AWS service. The capability to run serverless functions on demand and at scale is very powerful. A more recent capability of Lambda is that it can be run in response to certain Cloud Front events. AWS Cloud Front is a content delivery network. This integration of Lambda is referred to as Lambda Edge. You can use Lambda Edge the same way that you use normal Lambda. However, as a trigger you select Cloud Front and select the associated distribution and events to use as triggers.

Amazon Web Services Lambda.
When you use Cloud Front as a trigger, you can then access the option within your latest Lambda function to deploy to Lambda@Edge. This option will deploy your Lambda function across the Cloud Front edge servers kind of like a Cloud Front invalidation.

Amazon Web Services Lambda With Deploy to Edge.
This is where it becomes a little more complex. Thankfully the same code is deployed to all edge servers.

Cloud Watch Regions.
The biggest tip is to use CloudWatch logs to see if your functions are running. The big catch here is that your CloudWatch logs will be within the region of the originating requests. There are a LOT of regions. Thankfully you can do simple logging in Lambda by typical language console output methods. For Node Console.log will do the job. For Java System.out.println and the like will get output into your CloudWatch logs.

Amazon Cloud Watch Logs.
Also, watch out for lagging code deployment. As of August, 2019 I have experienced lagging edge deployments when using "Deploy to Lambda@Edge". I waited a day and the correct code was magically running.

Comments:0

Business Leadership and the 2019 Polar Vortex

Mon, 1 Apr 2019 11:53:52 EST

In January and February of 2019 a phenomenon called a polar vortex enveloped most of the midwestern United States. This polar vortex was linked to record low temperatures for a sustained period of a week or two and turbulent winter weather. Many portions of the state of Michigan also experienced significant, relentless, snowfall during this same time period. This combination of low temperatures and snowfall created deadly road conditions. Road crews typically apply large concentrations of salt to prevent ice buildup. However, with temperatures near or below zero degrees road salt does not work.

A photo of a field during the Polar Vortex of 2019.
I found myself baffled by business behavior during this polar vortex phenomenon. Many businesses remained open and expected employees to commute during the most deadly road conditions in the last decade. I am assuming that many of these businesses were caught off gaurd during the first few days of this uncommon event. However, the message was clear from organizations that offered no quarter for employees during these dangerous times. "As an employee you are an insignificant individual. You are replacable. Your health and safety do not matter to this company." That's a powerful message to inadvertantly resonate throughout an organization and one that should be avoided at all costs.

This powerful message may have been unavaoidable for many businesses as they must have staff on-site to operate. Two quick examples are restaraunts and gas stations. Without employees physically at those businesses they could not remain open.

The polar vortex phenomenon provided management at all levels of business an opportunity to practice empathetic leadership. We must ask ourselves how could management successfully navagate this unperdictable and tough situation? A few suggestions without significantly impacting the bottom line are:

A photo of a parking lot during the Polar Vortex of 2019.
1. Does the work environment allow work from home accomodation? Most businesses in 2019 have the capability to allow employees to work from home but they do not allow it for reasons including data security, low trust of employees, outdated business processes, and a host of other complex scenarios.

2. If employees cannot work from home; can we allow them to flex their schedule without loosing PTO time? Like letting employees work on days they normally are off when weather will be better.

3. If the business has no choice but to require employees to be at work, can they operate with reduced staff? Could the business offer overtime or time + 1/2 to employees who are willing to cover for other employees who live farther away and cannot make the commute?

One of my favorite leadership books, "Leadership is an Art" by Max Depree focuses primarily on the principle of humane leadership. The concept of humane leadership in essance is the liberation of people to do the work that is required of them in the most humane way possible.

A few concepts from the book exemplify this situation well: "Leaders don't inflict pain; they bear pain.". During the polar vortex, those leaders that beared the burdon of reduced staff bore pain. Those that did not address the risk to their staff inflicted pain.

"The first responsibility of a leader is to define reality. The last is to say thank you. In between the two, the leader must become a servant and a debtor." The polar vortex provided an opportunity to define reality. Was it defined as a hostile work environment, or an environment of empathy? Either way the leadership incurred debt in decreased work morale due to no accomodation or complexity in organizing business activity with staffing constraints.

Comments:0

Amazon S3 Static Website Iframe Responsive Problems

Sun, 29 Jul 2018 21:53:51 EST

Amazon S3 has a neat and very affordable feature that allows users to host a static website from inside an S3 bucket. In 2017, I switched hosting of this website to the S3 bucket method. It reduced hosting costs per year significantly. However, there are a few catches when hosting a website out of an S3 bucket. The primary catch we will discuss today involves an iframe that is placed around content when not using the absolute URL to the Amazon bucket.

For example, this websites' absolute url within the Amazon system is: http://technogumbo.com.s3-website-us-east-1.amazonaws.com

Utilizing bucket and dns configurations, a user is able to load this content from their registered domain. When doing this, Amazon must load the content at the absolute url within an iframe.

The main website and the CSS associated with it were originally created before the iPad1 launched! It was before the responsive age we now live in. As a result; I did a few modifications when switching to the static S3 bucket configuration. However, the presence of the iFrame has been constantly breaking responsive display for this site since 2017. The resume section was created after the main site, so that has remained responsive despite the iframe.

Recently, I took the time to dig into the problem and figure out an intermediate solution. The core problem is that this website specifies an 800 pixel minimum width. There are several other features that push out to that width inside the three columns that make up the interior of the site. In modern mobile and desktop browsers, the viewport will initially scale a site with a fixed interior width like this!

With the presence of the Amazon iFrame the browser has no clue what the actual content size is and has no way to automatically scale the content.

The best solution would be to re-do the site and create a revised 2018 looking style. However, an intermediate few hour solution is this:

1. After the content loads, use Javascript to examine the device width.
2. If the device width is under our fixed width, 800px; set the scale of our body element to the desired size to be able to see most of the content inside the iframe.

Using these two steps, this will restore the nice functionality where the browser automatically scales the viewport so users can see the entire content area. This code uses jquery because it is already included in the site; but the basic Javascript DOM reference can allow you to easily select the main body. Here is the code I am using:

  function TryResizeParentFrame() {
   try {
    if(window) {
     if( $(window).width() < 800) {
      var desiredWScale = $(window).width() / 800;
      $(window.document.body).css('zoom', desiredWScale);
      $(window.document.body).css('-moz-transform-origin', '0 0');
      $(window.document.body).css('-moz-transform', "scale{" + desiredWScale + ")");
     }
    }
   } catch(e) {
    if(console) console.warn("Sorry; unable to scale parent. The viewing experience may not be optimal: " + e);
   }
  }

Comments:0
Techno Gumbo RSS Feed Michigan Livestock Data Services The Research Computing and Engineering Podcast