Skip to content

Instantly share code, notes, and snippets.

View wcheek's full-sized avatar

Wesley Jon Cheek wcheek

  • Satake Japan
  • Hiroshima, Japan
  • 23:55 (UTC +09:00)
View GitHub Profile
@wcheek
wcheek / mount-s3-watchdog.sh
Last active April 9, 2025 04:20
mount-s3 on Amazon Linux 2 connection watchdog script
#!/bin/bash
#
# mount-s3-watchdog.sh
# Inspiration from https://github.com/s3fs-fuse/s3fs-fuse/issues/152
# Run from the root user's crontab to keep an eye on mount-s3 which should always
# be mounted.
#
# Note: If getting the amazon S3 credentials from environment variables
# these must be entered in the actual crontab file (otherwise use one
# of the s3fs other ways of getting credentials).
@wcheek
wcheek / rust_is_monotonic.rs
Last active March 11, 2025 04:22
Checks whether an array of numbers is monotonically increasing or decreasing
fn is_monotonic(data: &[u32]) -> bool {
if data.len() <= 2 {
return true;
}
let direction = data[1].cmp(&data[0]);
for i in 2..data.len() {
if breaks_direction(direction, data[i], data[i - 1]) {
return false;
}
@wcheek
wcheek / aws_cdk_pipeline_setup.py
Created September 27, 2023 03:00
AWS CDK Python with NodeJS Dependencies
from aws_cdk importpipelines
# This pipeline deploys a cdk stack
pipeline = pipelines.CodePipeline(
scope=self,
id="Pipeline",
code_build_defaults=code_build,
synth=pipelines.ShellStep(
id="Synth",
input=pipelines.CodePipelineSource.git_hub(
repo_string="MYREPO",
@wcheek
wcheek / Bucket_deployment.py
Last active October 21, 2022 01:30
Trying to bundle web app locally.
s3_deploy.BucketDeployment(
scope=self,
id="websiteDeploy",
sources=[
s3_deploy.Source.asset(
path="website",
bundling=BundlingOptions(
command=[
"bash",
"-c",
@wcheek
wcheek / website_deploy.py
Last active October 19, 2022 07:23
CDK Pipelines aws_codepipeline Website Deployment
from aws_cdk import Stack, aws_s3
from aws_cdk import aws_secretsmanager as secretsmanager
from aws_cdk.aws_codebuild import (
BuildEnvironment,
ComputeType,
LinuxBuildImage,
PipelineProject,
)
from aws_cdk.aws_codepipeline import Artifact, Pipeline
from aws_cdk.aws_codepipeline_actions import (
@wcheek
wcheek / App.vue
Created June 21, 2022 00:27
Authentication using AWS Amplify auth, loading external script
<script setup>
import { onMounted } from "vue";
import { Authenticator } from "@aws-amplify/ui-vue";
import "@aws-amplify/ui-vue/styles.css";
onMounted(() => {
const lex = document.createElement("script");
lex.src = "https://d2hzdehb4i1g7i.cloudfront.net/lex-web-ui-loader.min.js";
lex.onload = async function () {
const loaderOpts = {
baseUrl: "https://d2hzdehb4i1g7i.cloudfront.net/",
import React from "react";
import { Amplify } from "aws-amplify";
import {
AmplifyProvider,
Authenticator,
Button,
Flex,
Image,
Text,
View,
@wcheek
wcheek / attached_EFS.py
Created April 22, 2022 08:04
AWS CDK EC2 instance with EFS attached
self.file_system.connections.allow_default_port_from(self.ec2_instance)
self.ec2_instance.user_data.add_commands(
"yum check-update -y",
"yum upgrade -y",
"yum install -y amazon-efs-utils",
"yum install -y nfs-utils",
"file_system_id_1=" + self.file_system.file_system_id,
"efs_mount_point_1=/mnt/efs/fs1",
'mkdir -p "${efs_mount_point_1}"',
@wcheek
wcheek / README.md
Last active April 13, 2022 03:55
pymodbus context manager - manage TCP connection

A simple context manager to manage the connection to a TCP Modbus slave using pymodbus.

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
import json
import boto3
import zipfile
import urllib as urllib2
import io
import os
import time