This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Description: Create an S3 bucket with a lifecycle rule to expire current versions of objects after 1 day | |
Resources: | |
MyS3Bucket: | |
Type: 'AWS::S3::Bucket' | |
Properties: | |
BucketName: bucket-test-auto-removal | |
LifecycleConfiguration: | |
Rules: | |
- Id: ExpireObjectsAfterOneDay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function downloadTableAsCSV(tableId, filename) { | |
const rows = document.querySelectorAll(`#${tableId} tr`); | |
const csv = []; | |
for (const row of rows) { | |
const cols = row.querySelectorAll('td, th'); | |
const csvRow = Array.from(cols).map(col => { | |
const data = col.innerText.replace(/"/g, '""'); // Escape double quotes | |
return `"${data}"`; // Wrap in quotes | |
}).join(','); // Join columns with a comma |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@startuml | |
title Microservices Architecture on AWS | |
node "Microservice 1: User Service" as user_service { | |
database "PostgreSQL Database" as user_db | |
} | |
node "Microservice 2: Merchant Service" as merchant_service { | |
database "PostgreSQL Database" as merchant_db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pandas as pd | |
from pytz import timezone | |
# Read the original CSV file | |
csv_file_path = input('enter csv path ') | |
df = pd.read_csv(csv_file_path) | |
# Extract month and year from 'created_at' | |
df['created_at'] = pd.to_datetime(df['created_at']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mysql.connector | |
def fetch_rows_as_generator(query, chunk_size=100): | |
connection = mysql.connector.connect( | |
host='localhost', | |
user='your_username', | |
password='your_password', | |
database='your_database' | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import json | |
class LambdaClient: | |
def __init__(self, function_name): | |
self.function_name = function_name | |
self.client = boto3.client('lambda') | |
def invoke_function(self, payload): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from datetime import datetime, timedelta | |
from functools import wraps | |
class throttle(object): | |
""" | |
Decorator that prevents a function from being called more than the request limit every | |
time period. | |
To create a function that cannot be called more than 10 ten time in a minute: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function fetchData1() { | |
// Simulate API 1 call (e.g., fetching data) | |
await new Promise((resolve) => setTimeout(resolve, 1000)); | |
return 'Data from API 1'; | |
} | |
async function fetchData2() { | |
// Simulate API 2 call (e.g., fetching data) | |
await new Promise((resolve) => setTimeout(resolve, 1500)); | |
return 'Data from API 2'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Description: Creates RDS MySQL Database in specific VPC | |
Parameters: | |
ResourceNamePrefix: | |
Type: String | |
Default: testing # You can change the default prefix as needed | |
RDSDBMasterUsername: | |
Type: String | |
Description: RDS db master username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Description: Creates customizable ElastiCache Redis instance. | |
Parameters: | |
RedisCacheNodeType: | |
Type: String | |
Default: cache.t3.micro | |
Description: The compute and memory capacity of the nodes in the node group. | |
SecurityGroup: |
NewerOlder