Skip to content

Instantly share code, notes, and snippets.

View dsl2022's full-sized avatar
🏠
Working from home

DSL dsl2022

🏠
Working from home
View GitHub Profile

Advanced Shell Commands Exercise:

  1. Display Your Current Location
    • Print the current directory.
      pwd

Challenge 1: Summing Values using reduce

Write a function called sumArray that takes an array of numbers as input and returns the sum of all the numbers using the reduce method.

Example:

const numbers = [1, 2, 3, 4, 5];
const sum = sumArray(numbers);
console.log(sum);
  1. Which command is used to create a new database in MongoDB? a) use dbname b) create database c) db.createDatabase('dbname') d) db.createCollection('dbname')

  2. How can you create a collection named "destinations" in the "travelr" database? a) db.createCollection('travelr.destinations') b) db.createCollection('destinations', 'travelr') c) db.createCollection('destinations')

import boto3
def update_dynamodb_records(table_name, primary_key, new_field_name, new_field_value):
# Create DynamoDB client
dynamodb = boto3.client('dynamodb')
# Update the records
for key_value in primary_key:
response = dynamodb.update_item(
TableName=table_name,
import boto3
def scan_dynamodb_gsi(table_name, index_name, account_tokens_file, output_file):
# Read account tokens from file
with open(account_tokens_file, 'r') as file:
account_tokens = [line.strip() for line in file if line.strip()]
# Create DynamoDB client
dynamodb = boto3.client('dynamodb')

DynamoDB Record Deletion Script

This Python script allows you to delete records from a DynamoDB table by providing the table name and a list of primary keys. It utilizes the Boto3 library to interact with DynamoDB.

Prerequisites

  • Python 3.x
  • Boto3 library

Installation

import boto3
import argparse
def delete_records(table_name, primary_keys):
# Create DynamoDB client
dynamodb = boto3.client('dynamodb')
# Delete records one by one
for key in primary_keys:
locals {
upload_directory = "${abspath("${path.root}/../..")}${var.static_content_directory}"
app_fileset = fileset(local.upload_directory, "**/*.*")
}
variable "mime_types" {
default = {
htm = "text/html"
html = "text/html"
css = "text/css"
import time
import boto3
import json
sqs = boto3.resource('sqs')
sqs_client = boto3.client('sqs')
queueURL = "https://sqs.us-east-1.amazonaws.com/212612999379/terraform-example-deadletter-queue"
queueURL2 = "https://sqs.us-east-1.amazonaws.com/212612999379/terraform-example-deadletter-queue-2"
queueURL3 = "https://sqs.us-east-1.amazonaws.com/212612999379/terraform-example-deadletter-queue-3"
queueURL4 = "https://sqs.us-east-1.amazonaws.com/212612999379/terraform-example-deadletter-queue-4"
queueURL5 = "https://sqs.us-east-1.amazonaws.com/212612999379/terraform-example-deadletter-queue-5"

afdafafsadfsafafafafdsadd