Thursday, June 19, 2025

User Guide Mini Crane Scale KLAU Model OCS-L

I purchased this scale and it came with this booklet. However, I couldn't find this guide online so I've copied it here for easy reference.


 







Thursday, November 14, 2024

AWS CDK Get Parameter Store Value

Problem:

There are multiple ways to get a parameter store value. Which one should I use?

Solution:

1. Resolve at deploy time with no extra synth:

Use this pattern when you need the parameter value to resolve at deployment time rather than during `cdk synth`. This avoids CDK context lookups, cached values, and "double synth" behavior when parameters differ per environment.

const value = ssm.StringParameter.fromStringParameterAttributes(this, 'Param', {
  parameterName: '/my/plain/parameter',
}).stringValue;

// For secure parameters
const secret = cdk.SecretValue.secretsManager('/my/secure/parameter');

2. Resolve at synth time:

Use this syntax when you need a fixed, environment-specific value at synthesis time instead of at deployment. This retrieves the actual SSM parameter value during cdk synth and stores it in the cdk.context.json file. Use this approach when conditional logic in your CDK code requires the literal value (e.g., if/else branching to decide which stacks or resources to include).

const value = ssm.StringParameter.valueForStringParameter(this, '/my/plain/parameter');

// For secure parameters
const secret = cdk.SecretValue.ssmParameter('/my/secure/parameter');


3. Synthesis-time value (lookup)

Use this when you need the actual parameter value at synthesis time (not deployment). CDK will resolve it during `cdk synth`, cache it in `cdk.context.json`, and reuse it until refreshed. Ideal for feature flags or conditional logic that must run before deployment. Avoid for frequently changing values—requires re-synth to update.

const value = ssm.StringParameter.valueFromLookup(this, 'my-parameter-name');

https://docs.aws.amazon.com/cdk/v2/guide/get_ssm_value.html

Monday, October 7, 2024

AWS CDK Set CloudFormation Property Escape Hatch

 Problem:

The CDK does not always support all CloudFormation properties. A super simple escape hatch is to use  a addOverride one-liner. There are more robust escape hatches but this is super simple especially for deeply nested properties. Ideally, these are temporary until the CDK exposes properties directly.

Solution:

// The CDK does not currently support dynamic wildcard branch names (and other GitHub version 2 properties) but CloudFormation does.
const cfnPipeline = pipeline.node.defaultChild as codepipeline.CfnPipeline;
cfnPipeline.addOverride('Properties.Stages.0.Actions.0.Configuration.BranchName', `*-${env}-*`);

Wednesday, June 26, 2024

AWS CDK Chart.js Canvas Layer for AWS Lambda

 Problem:

Using the AWS CDK v2, how to deploy the "Canvas Layer for AWS Lambda" serverless application and attach the layer to a Lambda function.

lambda-layer-canvas-nodejs

https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:990551184979:applications~lambda-layer-canvas-nodejs

https://charoitel.github.io/lambda-layer-canvas-nodejs/

To get the latest semanticVersion:

  1. Open the AWS Management Console.
  2. Navigate to the Serverless Application Repository.
  3. Search for lambda-layer-canvas-nodejs.
  4. View the application details to find the latest version.

Solution:

import { Stack } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { CfnApplication } from 'aws-cdk-lib/aws-sam';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import * as lambdaNJS from 'aws-cdk-lib/aws-lambda-nodejs';

export default class ChartStack extends Stack {
    constructor(scope: Construct, id: string, props: cdk.StackProps) {
        super(scope, id, props);

        const chartJsApp = new CfnApplication(this, 'ChartJsApp', {
            location: {
                applicationId: 'arn:aws:serverlessrepo:us-east-1:990551184979:applications/lambda-layer-canvas-nodejs',
                semanticVersion: '2.11.3'
            }
        });

        const layerArn = chartJsApp.getAtt('Outputs.LayerVersion').toString();

        const njs = new lambdaNJS.NodejsFunction(this, 'ChartLambda', {
            entry: 'main.ts',
            handler: 'handler',
            runtime: lambda.Runtime.NODEJS_18_X,
            layers: [lambda.LayerVersion.fromLayerVersionArn(this, 'ChartJsLayer', layerArn)]
        });

        // Add dependency to ensure the layer is deployed before the function
        njs.node.addDependency(chartJsApp);
    }
}

Tuesday, May 28, 2024

AWS CDK V2 Synth Error when Bundling a NodejsFunction

 Problem:
AWS CDK version 2 synth error when bundling a NodejsFunction with somewhat complicated Typescript source code.

Error:
RangeError: Maximum call stack size exceeded

Solution:
Upgrade to a more recent version of npm package "esbuild". In this case, upgrading to version 0.19.12 resolve the issue even though this isn't the most recent version available. Other third party npm package constraints did not allow the latest version to be installed. npm i -D esbuild@0.19.12


Friday, May 3, 2024

AWS Lambda Typescript Ends Unexpectedly

 Problem:

An AWS Lambda in TypeScript ends unexpectedly with a CloudWatch success message (i.e. no errors logged).

Solution:

a. Increase Lambda memory size if low.

b. Check for missing await. Various console.log statements might log to CloudWatch but Lambda does not run to completion.

Wednesday, March 20, 2024

Developer Setup on Windows

Windows

  1. Display settings.

Install 

  1. Google Chrome
    • Make default browser
    • Plugins:
      • AWS Extend Switch Roles
      • Bitwarden
      • Session Buddy
  2. Firefox + Edge + Brave
  3. NVidia GeForce Experience (use to download latest drivers)
  4. Git for Windows
  5. TortoiseGit
    • git config --global --add safe.directory 'c:/myfolder'
    • github will prompt to login via browser
  6. Visual Studio Code
  7. Node.js includes npm
  8. AWS CLI
  9. MySQL Workbench
  10. Notepad++
  11. Draw.io
  12. SnagIt
  13. Camtasia
  14. MS office + teams + skype
    •  Configure Outlook to open links in default browser.
  15. Open OneDrive and login to accounts to view files on local
  16. Adobe Acrobat Reader
NPM
  • npm install -g @ionic/cli
  • npm install -g @angular/cli
Visual Studio Code
  • Command Palette > Open User Settings JSON
    {
        "typescript.implementationsCodeLens.enabled": true,
        "[typescript]": {
            "editor.detectIndentation": false,
            "editor.tabSize": 4,
        },
        "[html]": {
            "editor.detectIndentation": false,
            "editor.tabSize": 4
        }
    }

Troubleshooting
  • speedtest.net (internet connection speed test)
  • 3DMark demo (for basic GPU/CPU benchmark)