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 | |
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') |
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 | |
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) |
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
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 |
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
--- | |
# 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: |
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
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/ && \ |
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
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 |
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
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 |
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
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 = ""; |
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
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 |