Skip to content

Instantly share code, notes, and snippets.

View ugwulo's full-sized avatar
👋
Exploring

Johnpaul Ugwulo ugwulo

👋
Exploring
View GitHub Profile
@ugwulo
ugwulo / upload.py
Created May 3, 2025 04:12
Upload To S3 Bucket
import boto3
s3_client = boto3.client('s3')
print(s3_client.create_bucket(
Bucket='large-file-1234567890-bucket',
))
response = s3_client.upload_file('./newsCorpora.csv', 'large-file-1234567890-bucket', 'dami/newsCorpora.csv')
@ugwulo
ugwulo / s3_copy.py
Created May 3, 2025 04:09
Cross Account S3 Object Copy/Sync
import boto3
s3_client = boto3.client('s3')
source_bucket = 'large-file-1234567890-bucket'
destination_bucket = 'sagemaker-studio-463929498748-kmeswwi96y'
# List all objects in the source bucket
response = s3_client.list_objects_v2(Bucket=source_bucket)
@ugwulo
ugwulo / thread.py
Created May 3, 2025 04:05
AWS Boto3 Threading
try:
import logging
import boto3
from botocore.exceptions import ClientError
import os
import sys
import threading
import math
import re
from boto3.s3.transfer import TransferConfig
---
# N.B: I used AWS CLI and Vault, so I didn't need to explicitely define the access key ID and token for my IAM user role
# usage >> "AWS_PROFILE=profile-name ansible-playbook altschool-vpc-playbook.yml"
- hosts: localhost
gather_facts: no
tasks:
# Create the vpc
- name: create altschool vpc.
amazon.aws.ec2_vpc_net:
All the commands are executed in WSL2.
Download and "install" aws-vault
# Download
AWS_VAULT_VERSION="v6.3.1" && \
wget -O aws-vault "https://github.com/99designs/aws-vault/releases/download/${AWS_VAULT_VERSION}/aws-vault-linux-amd64"
# Install
sudo mv aws-vault /usr/local/bin/ && \
String Tests and Operations
Create a file named teststrings.sh, with the content below.
#!/bin/bash
# check two string arguments were given
[[ $# -lt 2 ]] && \
echo "Usage: Give two strings as arguments" && exit 1
str1=$1
str2=$2
Arithmetic and Functions
Create a file named testmath.sh, with the content below.
#!/bin/bash
# Functions. must be before the main part of the script
# in each case method 1 uses $((..))
# method 2 uses let
# method 3 uses expr
package com.ugwulo;
import java.util.*;
/**
* @author Ndunuisi Ugwulo 05/16/2020
*/
public class GreatestSmallestString {
public static String getSmallestAndLargest(String s, int k) {
String smallest = "";
@ugwulo
ugwulo / GCD.java
Created May 16, 2020 15:06
Finding the Greatest Common Divisor using Euclid's Algorithm
package com.ugwulo;
/** @author Ndubuisi Ugwulo
* Date: 05:16:2020
* Greatest Common Divisor using Euclid's algorithm
*/
public class GCD {
/**
* @param numerator first number
* @param denominator second number