This file contains hidden or 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 os | |
import time | |
import json | |
import uuid | |
# Initialize AWS clients | |
s3 = boto3.client('s3') | |
athena = boto3.client('athena') |
This file contains hidden or 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 csv | |
import io | |
import time | |
import json | |
import uuid | |
# AWS Clients | |
s3 = boto3.client('s3') | |
athena = boto3.client('athena') |
This file contains hidden or 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 asyncio | |
import aiohttp | |
# Exponential backoff and retry function | |
async def fetch_with_retries(session, url, retries=5, backoff_factor=1): | |
attempt = 0 | |
while attempt <= retries: | |
try: | |
async with session.get(url) as response: | |
print("Attempt", attempt, "for", url) |
This file contains hidden or 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 hashlib | |
import boto3 | |
from boto3.s3.transfer import S3Transfer | |
def calculate_checksum(file_path, algorithm='sha256'): | |
""" | |
Calculate the checksum of a file on disk. | |
:param file_path: Path to the file | |
:param algorithm: Checksum algorithm (default is sha256) | |
:return: checksum as a hexadecimal string |
This file contains hidden or 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 re | |
def format_string(input_string): | |
# Remove spaces and capitalize the first letter after each space | |
result = re.sub(r'(\s+)(\w)', lambda match: match.group(2).upper(), input_string.replace(' ', '')) | |
return result | |
# Example usage: | |
input_string = "hello world example string" |
This file contains hidden or 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
#!/bin/bash | |
# Function to check if the given date is a weekday | |
is_weekday() { | |
day_of_week=$(date -d "$1" +%u) | |
if [[ "$day_of_week" -ge 1 && "$day_of_week" -le 5 ]]; then | |
return 0 # Weekday | |
else | |
return 1 # Weekend | |
fi |
This file contains hidden or 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
Sub TopologicalSortAndModifyTablesWithRemapLogic() | |
Dim lastRow As Long | |
Dim i As Long | |
Dim job As String ' Job name (String) | |
Dim dependentJob As String ' Dependent job (String) | |
Dim jobList As Object | |
Dim inDegree As Object | |
Dim queue As Collection | |
Dim result As Collection | |
Dim currentJob As Variant ' To loop over sorted jobs |
This file contains hidden or 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 java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.io.IOException; | |
public class ProcessBuilderExample { | |
public static void main(String[] args) { | |
// Create a ProcessBuilder instance to run the 'ls' command | |
ProcessBuilder processBuilder = new ProcessBuilder("ls", "-l"); // You can add other options as needed | |
try { |
This file contains hidden or 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
cat typescript | perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g' | col -b > typescript-processed |
This file contains hidden or 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
#include <bits/stdc++.h> | |
bool iterateFile(std::string fileName, std::function<void (const std::string & )> callback) | |
{ | |
std::ifstream in(fileName.c_str()); | |
if(!in) | |
{ | |
std::cerr << "Cannot open the File : "<<fileName<<std::endl; | |
return false; | |
} |
NewerOlder