Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lab4 pull #113

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions my-work/lab3/convert-bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

curl https://s3.amazonaws.com/ds2002-resources/labs/lab3-bundle.tar.gz

tar -xzf lab3-bundle.tar.gz

awk '!/^[[:space:]]*$/' lab3_data.tsv > my_file.tsv

awk 'BEGIN { FS="\t"; OFS="," } {$1=$1; print}' my_file.tsv >
my_file.csv


linecount=$(wc - l my_file.csv)
echo "The number of lines in the .csv file is $linecount."

tar -cvf converted-archive.tar.gz my_file.csv

17 changes: 17 additions & 0 deletions my-work/lab3/github-events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/opt/anaconda3/bin/python3

import os
import json
import requests

GHUSER = os.getenv('ziyajasani')

url = "https://api.github.com/users/{0}/events'.format(GUSER)

r = json.loads(requests.get(url).text)

for x in r[:5]:
event = x['type'] + ' :: ' + x['repo']['name']
print(event)

print(r)
20 changes: 20 additions & 0 deletions my-work/lab3/madlib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash


clear
echo "Let's build a mad-lib!"

read -p "1. Name your favorite color: " COLOR
read -p "2. Name your favorite food: " FOOD
read -p "3. Name your favorite season: " SEASON
read -p "4. Name your favorite animal: " ANIMAL
read -p "5. Name your favorite hobby: " HOBBY
read -p "6. Night time or day time?: " TIME
read -p "7. Swimming in the pool or ocean?: " SWIMMING
read -p "8. Name your favorite fruit: " FRUIT

echo "Once upon a $SEASON, there was a $COLOR $ANIMAL who loved to grub on
food any chance they got, especially $FOOD. The $ANIMAL had a playdate
planned out with their friends during the $TIME where they were planning
on $HOBBY. However, the $ANIMAL spotted $FRUIT in the $SWIMMING. They
ditched their friends, jumped right in, and munched happily ever after."
Empty file added my-work/lab3/my_file.tsv
Empty file.
Binary file added my-work/lab4/beach.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions my-work/lab4/bucket.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

curl https://royvon.co.uk/wp-content/uploads/2021/10/Our-Story-About-Royvon-1.jpg > dog.jpg

aws s3 cp dog.jpg s3://ds2022-eme4de

aws s3 presign --expires-in 604800 s3://ds2022-eme4de/dog.jpg

https://ds2022-eme4de.s3.us-east-1.amazonaws.com/dog.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAUPMYNIILKRYU3I6O%2F20241003%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20241003T184532Z&X-Amz-Expires=604800&X-Amz-SignedHeaders=host&X-Amz-Signature=5e690df66c9db1e3a2eee3be0aace9517d6624cd38c21443e1fb1c710c85a3c1

Binary file added my-work/lab4/dog.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added my-work/lab4/flowers.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions my-work/lab4/lab4_second_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/python3

import urllib.request
import boto3

url = 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'

bucket = 'ds2022-eme4de'
expires_in = 604800

urllib.request.urlretrieve(url, 'flowers.jpg')

local_file = 'flowers.jpg'
object_name = 'flowers.jpg'

s3 = boto3.client('s3', region_name="us-east-1")

resp = s3.put_object(
Body = local_file,
Bucket = bucket,
Key = local_file,
ACL = 'public-read'
)

s3.upload_file(local_file, bucket, object_name)

response = s3.generate_presigned_url(
'get_object',
Params={'Bucket': bucket, 'Key': object_name},
ExpiresIn=expires_in
)

print(response)

#https://ds2022-eme4de.s3.amazonaws.com/flowers.jpg?AWSAccessKeyId=AKIAUPMYNIILKRYU3I6O&Signature=6mYO61IiQLzGFokAUSW0SyyJt4c%3D&Expires=1728595188
Empty file added my-work/lab4/tacobell
Empty file.
Binary file added my-work/lab4/tacobell.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions my-work/list-classmates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

#tells code to stop running when there is an error
set -e

#move into the people directory
cd ../people

#look for README
target_file="README.md"

#loop through the dirs and find target file
for dir in $(find . -type of d); do
if [-f "$dir/$target_file"]: then
# echo "$dir/$target_file";
name=`head -n 1 "$dir/$target_file"`;
echo $name;
fi
done