Skip to content

Instantly share code, notes, and snippets.

View Siddhant-K-code's full-sized avatar
🚀
Shipping

Siddhant Khare Siddhant-K-code

🚀
Shipping
View GitHub Profile
@Siddhant-K-code
Siddhant-K-code / linux-quotes-notes.md
Created September 4, 2024 02:02
Linux: Difference Between Single Quotes, Double Quotes, and Backquotes

1. Introduction

In Linux, single quotes ('), double quotes ("), and backquotes (`) serve different purposes. The easiest way to understand their differences is by using the DATE variable, the "date" string, and the date command.

[Difference in Quotation Marks]

Important:

  • ' ... Single quotes
    • Everything within single quotes is interpreted as a string (ignoring any variables).
  • " ... Double quotes
@Siddhant-K-code
Siddhant-K-code / Enable-Touch-ID-Authentication-for-sudo-on-MacOS-Sonoma.md
Last active June 22, 2024 11:32
Enable Touch ID Authentication for sudo on MacOS Sonoma

Enable Touch ID Authentication for sudo on macOS Sonoma 14.x

Operating Environment:

  • OS: MacOS Sonoma 14.5
  • Device: M1 MacBook Pro

Explanation

In macOS Sonoma, a new method has been introduced to enable Touch ID when running sudo commands, making it more persistent across system updates. Previously, editing the /etc/pam.d/sudo file was necessary, but these changes would often revert after an update, requiring reconfiguration. With Sonoma, the settings can be added to a separate file /etc/pam.d/sudo_local, which isn't overwritten during updates, allowing Touch ID to remain enabled for sudo commands consistently.

@Siddhant-K-code
Siddhant-K-code / > vs | in YAML.md
Created May 30, 2024 20:00
`>` v/s `|` in YAML files

In YAML, the | and > characters are used to denote different styles of multi-line strings. Here's a brief explanation of each:

| (Literal Block Scalar)

The | character is used to preserve the exact formatting of the multi-line string, including line breaks and leading spaces. It's useful when you want to maintain the formatting of the text exactly as it is.

Example:

example_literal: |
  This is a literal block scalar.
 It preserves line breaks and
@Siddhant-K-code
Siddhant-K-code / upload-download-aws-s3-objects-in-go.md
Created May 23, 2024 10:23
Upload and Download AWS S3 Objects in Go

Upload and Download AWS S3 Objects in Go

This Gist demonstrates how to use the aws-sdk-go package to upload and download objects from AWS S3 using Go. It utilizes the s3manager package to simplify these operations.

Prerequisites

Before running the code, install the AWS SDK for Go using the following command:

$ go get github.com/aws/aws-sdk-go
@Siddhant-K-code
Siddhant-K-code / compress-decompress-files-in-go.md
Created May 23, 2024 10:17
How to gzip compress and decompress files using the compress/gzip package in Go.

Gzip and Decompress Files in Go

This Gist demonstrates how to gzip compress and decompress files using the compress/gzip package in Go.

Compress a File

This Go program compresses a file named hello.txt into a gzip file named hello.txt.gz using the best compression level available.

package main
@Siddhant-K-code
Siddhant-K-code / get-dynamodb-data-from-lambda.md
Created May 17, 2024 18:03
Node.js: How to Get DynamoDB Data from Lambda

Node.js: How to Get DynamoDB Data from Lambda

This guide introduces how to use AWS Lambda to retrieve data from DynamoDB. The data acquisition flow is as follows: API Gateway → Lambda → DynamoDB. This example focuses on the Lambda to DynamoDB part, omitting the details of invoking Lambda from the screen.

Source Code

Here is an example of retrieving data using userId as a condition.

const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
@Siddhant-K-code
Siddhant-K-code / count-items-dynamodb.md
Last active May 15, 2024 19:13
How to Count the Number of Items in DynamoDB Using the AWS CLI

How to Count the Number of Items in DynamoDB Using the AWS CLI

Retrieving the approximate number of items

You can use the describe-table command to easily get an approximation of the number of items from the metadata of a DynamoDB table. This saves time and money because you don't have to scan the entire table.

Example Command

aws dynamodb describe-table --table-name TableName --profile ProfileName --region RegionName
@Siddhant-K-code
Siddhant-K-code / concurrency-in-shell-scripts.md
Created May 11, 2024 07:04
Short notes: Parallel Execution Techniques in Shell Scripts

Implementing Concurrency in Shell Scripts

In this short note, we'll explore various techniques to achieve concurrency in shell scripts. Concurrency allows for executing multiple operations in parallel, which can dramatically reduce the processing time by handling tasks simultaneously. We'll cover several methods, from basic background execution to more sophisticated tools like GNU Parallel.

Basics of Concurrency in Shell Scripts

Concurrency in shell scripting is facilitated by executing multiple processes simultaneously. This parallel processing allows a script to initiate subsequent tasks without waiting for the previous tasks to complete.

1. Background Execution

@Siddhant-K-code
Siddhant-K-code / til-8-may-2024.md
Created May 8, 2024 04:34
TIL (05/08/2024): DynamoDB Query Evaluation Order Differs from SQL

DynamoDB Query Evaluation Order Differs from SQL

Summary:

When using LIMIT in DynamoDB queries, the order of evaluation can differ from SQL queries, potentially leading to unexpected results depending on the search criteria used.

SQL Query Evaluation Order:

SQL queries follow a specific order of evaluation:

FROM -> ON -> JOIN -> WHERE -> GROUP BY -> HAVING -> SELECT -> DISTINCT -> ORDER BY -> LIMIT
@Siddhant-K-code
Siddhant-K-code / aws-s3-bulk-deletion.md
Created April 28, 2024 04:03
AWS S3 Bucket bulk deletion

AWS S3 Bucket bulk deletion

To utilize the AWS CLI for listing S3 buckets and deleting those that match a specific pattern, follow these steps. This guide focuses on how to remove buckets starting with the prefix "sk."

Requirements

  • AWS CLI must be installed.
  • Appropriate AWS credentials and permissions should be set up.

Step 1: Get a List of Buckets First, use the AWS CLI installed on your machine to retrieve a list of all S3 buckets.