Skip to content

Instantly share code, notes, and snippets.

View jamby1100's full-sized avatar

Raphael Jambalos jamby1100

  • eCloudValley
  • Manila
View GitHub Profile
@jamby1100
jamby1100 / tcp_call_client.py
Last active December 24, 2021 10:55
This snippet is based off the work of Mathew Wachter (https://github.com/matthewwachter/py-tcp-threaded-server). I added modifications to allow it to communicate to Lambda via requests
import json
import socket
import os
# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Connect the socket to the port where the server is listening
ip_address = os.getenv("TCP_SERVER_IP_ADDRESS")
port = int(os.getenv("TCP_PORT_NUMBER"))
@jamby1100
jamby1100 / tcp_web_server_proxy.py
Created August 22, 2021 10:17
This snippet is based off the work of Mathew Wachter (https://github.com/matthewwachter/py-tcp-threaded-server). I added modifications to allow it to communicate to Lambda via requests
#!/usr/bin/python3
from datetime import datetime
import json
from pprint import pprint
import socket
import os
from threading import Thread
import requests
@jamby1100
jamby1100 / loyalty_app.oas.yml
Created March 24, 2021 16:13
OpenAPI 3.0 definition for Simple Loyalty Application
openapi: 3.0.0
info:
title: Loyalty Card API
version: "0.1"
components:
schemas:
User:
type: object
properties:
id:
@jamby1100
jamby1100 / lambda_at_edge_nodejs.js
Created February 7, 2021 15:45
Lambda function for enabling multiple Angular apps in 1 S3 bucket
exports.handler = (event, context, callback) => {
// Get the request object.
const request = event.Records[0].cf.request;
// Get the host from the request and take out "www." from the host if it exists.
let host = request.headers.host[0].value;
host = host.replace(/^www\./, "");
// Check if the host contains a subdomain.
@jamby1100
jamby1100 / aws_config_custom_rule.js
Last active February 20, 2020 10:40
This is a custom AWS Config rule that checks if an EC2 instance has the "department" tag. It also makes sure that department tag only contains a valid set of values defined in the AWS Config rules. You only need to change the `evaluateChangeNotificationCompliance` function in order to modify the logic of the rule.
function evaluateChangeNotificationCompliance(configurationItem, ruleParameters) {
// boilerplate code, dont change
checkDefined(configurationItem, 'configurationItem');
checkDefined(configurationItem.configuration, 'configurationItem.configuration');
checkDefined(ruleParameters, 'ruleParameters');
// check if the AWS Config rule that called this Lambda function
// defines the valid departments
if (ruleParameters.hasOwnProperty("validDepartments")) {
// pass
@jamby1100
jamby1100 / better_git_commit_parser.rb
Last active February 19, 2018 05:05 — forked from jamster/git_commit_parser.rb
quick script to parse git logs and turn them to a data structure
# Added support for merge messages
# Usage:
# git log | ruby git_commit_parser.rb
# https://gist.github.com/881641
# By: Jason Amster
# jayamster@gmail.com
# Forked from: https://gist.github.com/jamster/881641
require 'rubygems'
require 'pp'