Skip to content

Instantly share code, notes, and snippets.

View jsbonso's full-sized avatar
🎯
portal.tutorialsdojo.com

Jon Bonso jsbonso

🎯
portal.tutorialsdojo.com
View GitHub Profile
@jsbonso
jsbonso / aws-lambda-send-notif-to-tdojo-slack.py
Created July 11, 2022 23:03
Lambda Function that sends CloudWatch Logs notification to Slack
#
# Real-time Monitoring of 5XX Errors using AWS Lambda, CloudWatch Logs and Slack
# Author: Tutorials Dojo Team
#
import json
import urllib3
import base64, zlib
http = urllib3.PoolManager()
@jsbonso
jsbonso / AWS Lambda SSM Parameter Store Updater function.py
Last active February 11, 2024 02:25
AWS Lambda SSM Parameter Store Updater function
import boto3, os, json
REGION = os.environ['REGION']
ASG_NAME = os.environ['ASG_NAME']
SSM_PARAMETER_NAME = os.environ['SSM_PARAMETER_NAME']
ssm = boto3.client('ssm', region_name=REGION)
autoscaling = boto3.client('autoscaling', region_name=REGION)
def lambda_handler(event, context):
@jsbonso
jsbonso / asg-stop-start-inline-policy.json
Last active June 20, 2022 01:58
Inline Policy - Dynamic Start and Stop Scheduler Functions
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "Tutorials Dojo - DescribeAutoScalingGroups",
"Effect": "Allow",
"Action": "autoscaling:DescribeAutoScalingGroups",
"Resource": "*"
},
{
"Sid": "Tutorials Dojo - Allow PutParameter",
@jsbonso
jsbonso / start_scheduler_function.py
Last active February 11, 2024 02:26
Dynamic Start and Stop Scheduler Lambda Functions
import boto3, os, json, time
REGION = os.environ['REGION']
ASG_NAME = os.environ['ASG_NAME']
SSM_PARAMETER_NAME = os.environ['SSM_PARAMETER_NAME']
ssm = boto3.client('ssm', region_name=REGION)
ec2 = boto3.client('ec2', region_name=REGION)
autoscaling = boto3.client('autoscaling', region_name=REGION)
def lambda_handler(event, context):
@jsbonso
jsbonso / lambda_function.py
Last active February 11, 2024 02:27
Dynamic Start and Stop Lambda Scheduler Functions
import boto3, os, json, time
REGION = os.environ['REGION']
ASG_NAME = os.environ['ASG_NAME']
SSM_PARAMETER_NAME = os.environ['SSM_PARAMETER_NAME']
ssm = boto3.client('ssm', region_name=REGION)
autoscaling = boto3.client('autoscaling', region_name=REGION)
ec2 = boto3.client('ec2', region_name=REGION)
def lambda_handler(event, context):
@jsbonso
jsbonso / Dynamic Start and Stop Scheduler Functions.json
Last active February 11, 2024 02:20
Dynamic Start and Stop Scheduler Functions
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "Dynamic Start and Stop Scheduler Functions - Tutorials Dojo",
"Action": [
"autoscaling:EnterStandby",
"autoscaling:ExitStandby",
"autoscaling:PutScalingPolicy",
"autoscaling:SetDesiredCapacity"
],
@jsbonso
jsbonso / gist:d1d7d7b9e122ab0d0e5887bef2b499c3
Created October 27, 2020 10:38
List of AWS Pull-Requests
Tutorials Dojo is an active contributor to the official AWS documentation.
We've raised several pull-requests to the official AWS Github repositories that remediate incorrect information in the AWS docs, and not just simple grammar typos.
Here are the latest ones that got approved by the AWS team recently:
https://github.com/awsdocs/amazon-cloudwatch-user-guide/pull/42
https://github.com/awsdocs/elb-application-load-balancers-user-guide/pull/21
https://github.com/awsdocs/amazon-s3-developer-guide/pull/79
https://github.com/awsdocs/amazon-dynamodb-developer-guide/pull/207
@jsbonso
jsbonso / gist:f7dbe74c08124c12ab921d2746041a71
Created May 23, 2020 21:39
How to avoid your php file from being accessed directly
// Add this code to automatically
// exit if this php file is accessed directly
defined( 'ABSPATH' ) || exit;
@jsbonso
jsbonso / mac-updater.sh
Created January 7, 2020 05:58
Generates a new MAC address for your macbook to bypass the Free WIFI limit in Malls/ Cafes
#!/bin/bash
#
COUNTER=0
echo "Generating Random MAC Address..."
while [ $COUNTER -lt 100 ]; do
mac=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
#echo "$mac"
if [ ${mac:0:2} = 80 ]
then
echo "$mac"
@jsbonso
jsbonso / gist:85c65896b4054d69594f27c6ae28897a
Created May 14, 2019 03:31
NodeJS Script for Data Fetch
{
"name": "coral-livefyre-api-scraper",
"version": "1.0.0",
"description": " API scraper to fetch data and generate dump file",
"main": "index.js",
"scripts": {
"build": "rimraf dist/ && babel ./ --out-dir dist/ --ignore ./node_modules,./.babelrc,./package.json,./npm-debug.log --copy-files",
"start": "babel-node --presets es2015 index.js"
},
"keywords": [